1
2 3 4 5 6 7 8 9 |
|
1
|
|
1
|
|
1
2 3 |
|
1
2 3 |
|
1
2 3 |
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
1
2 3 4 5 |
|
1
2 3 4 5 6 7 8 9 |
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
1
|
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
1
2 3 4 |
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
1
2 |
|
1
|
|
1
|
|
1
2 3 4 |
|
1
|
|
1
2 3 4 5 6 7 8 |
|
1
2 3 4 5 6 7 8 9 10 |
|
1
|
|
1
|
|
1
|
|
Chrome / Firefox |
Safari |
Edge |
Safari on iPhone |
Chrome on Android |
IE 10 / 11 |
IE 8-9 |
||
Click to upload | Same-Domain | |||||||
Cross-Domain | ||||||||
Drag & Drop to upload | Same-Domain | |||||||
Cross-Domain | ||||||||
Upload multiple files at once | ||||||||
Get file metadata |
? |
|||||||
Image preview on upload | ||||||||
File type validation | ||||||||
File size validation | ||||||||
Custom file validation | ||||||||
Limit file type selection | ||||||||
Upload in chunks | Same-Domain | |||||||
Cross-Domain | ||||||||
Progress indication (with chunked upload) | Same-Domain | |||||||
Cross-Domain | ||||||||
Progress indication (without chunked upload) | Same-Domain |
? |
||||||
Cross-Domain | ||||||||
Modify plugin texts | ||||||||
Modify plugin CSS | ||||||||
Use custom design | ||||||||
Cancel upload | ||||||||
Disable / Enbale user interaction | ||||||||
Pre-define uploaded files | ||||||||
Right-to-left support | ||||||||
Show uploaded files | ||||||||
Trigger plugin events |
1
2 3 4 |
|
1
2 3 |
|
Option | Type | Description | ||||||
acceptOnlyFilesTypes default: null |
String |
Defines the input "accept" attribute, allowing the user to
select only certin file types.
Avaliable values can be "image/*" (to allow only images files selection such as JPG or PNG), "video/*" (to allow only video files selection), "text/html" (to allow user to select only HTML files), ".csv, application/vnd.ms-excel" (to allow only specific excel files), ect. Demo here. |
||||||
allowedFilesExtensions default: null |
Array |
Files extenstions list to validate.
If the array is populated and contains a list of files extenstions, the plugin would validate the file extension upon file selection. If each selected files matches one of the array memebers, files can be uploaded. If not, "invalid_file_extension" error is thrown. For example:
|
||||||
allowedMaxFileSize default: null |
Number |
Maximum allowed file size, in KB (1 KB = 1/1000 MB).
If the variable is populated with value bigger then 0, the plugin would validate the file size upon file selection. If each selected files size is less then given value, files can be uploaded. If not, "invalid_file_size" error is thrown. For example:
|
||||||
capture default: null |
String |
Force the use of a specific media element to upload the file from.
Avaliable values are - camera - Capture media directly from the device's camera. camcorder - Capture media directly from the device's video camera. microphone - Capture media directly from the device's microphone. filesystem - Capture media directly from the device's gallery. user - Capture media directly from the user-facing camera and/or microphone. environment - Capture media directly from the outward-facing camera and/or microphone. |
||||||
customHTML default: false |
Boolean |
If value is set to true, the plugin is being wraped under the
selected DOM element. So the element is receiving the SlashUploader functionality
and events, without changing its layout and design.
customHTML option can be declared only at initialization. For example:
|
||||||
customValidation default: null |
Function |
Validating with a custom function upon files selection. In case of an error,
function should return a custom error object.
For example:
|
||||||
disabled default: false |
Boolean |
If value is set to true, user interaction is disabled.
Demo here. |
||||||
displayErrorDuration default: 4500 |
Number |
Amount of time, in milliseconds, to display validation errors before hiding them.
Demo here. |
||||||
doGetFileMetadata default: true |
Boolean |
Determines if plugin would try to recieve files metadata upon selection.
Reading the file metadata might get heavy on the browser, if the file is big. So if there's no use for that option, better set it to false. SlashUploader plugin can get the following metadata for each file (as long as the user's browser provides the ability - have a look at the "Compatibility" table): file - native file object. name - file name. extension - file extension. type - file type. size - file size, in KB. duration - media file length in seconds. width - image / video file width in pixels. height - image / video file height in pixels. rotation - image rotation, based on the camera orientation when the picture was captured. |
||||||
enableCancelButton default: true |
Boolean |
Determines if plugin shows or hides the "Cancel" button while uploading file.
Demo here. |
||||||
enableDeleteButton default: true |
Boolean |
Determines if plugin shows or hides the "Delete" button (after file or files were
successfully uploaded) next to each uploaded file.
Demo here. |
||||||
enableDropFiles default: true |
Boolean |
Determines if drag & drop ability is allowed. If false, only click
ability is allowed to select files.
Demo here. |
||||||
fileSizeToForceChunksUpload default: 500000 |
Number | If one or more of the selected files size was larger then the value of fileSizeToForceChunksUpload (in KB), upload type is determined to be chunks upload (on browsers where possible) instead of stream upload. | ||||||
groupedUploadedFilesHtml
default: {{total_files}} files uploaded |
String | HTML template to display the uploaded files, if groupUploadedFilesResult is set to true. | ||||||
groupUploadedFilesResult default: false |
Boolean | If value set to true, then uploaded files results appear in one, combined row (using the template text of groupedUploadedFilesHtml parameter), instead of showing each uploaded file in its own row. | ||||||
height default: 80 |
String | Determines the height of the componenet, in pixels. | ||||||
iframeGateway default: SlashUploader/iframe_gateway.html |
String | Determines the relative location of "iframe_gateway.html" file. Iframe gateway is used as a fallback for browsers that have a strict cross-domain policy (such as Safari) or are just very old (such as IE 9). | ||||||
maxFileChars default: 20 |
Number |
Maximum characters length to display for a file name. Upon selection or upload of a
file, its name is being displayed, and if the file name length is more then the
given value - file name is being trimmed to the given value length.
Demo here. |
||||||
maxFiles default: 9999 |
Number |
Maximum amount of files to enable the user to upload.
Demo here. |
||||||
progressAnimationType default: inline |
String |
Files upload progress indication type.
Can have one of the following values: null - No progress animation is being displayed. inline - Progress animation is displayed inside the button itself. If an image is selected, the preview of the image is seen within the animation. bar - Progress bar animation is displayed with a filling bar. Value can also include two types with a "|" (vertical bar) separator. For example:
|
||||||
resetFilesOnEachUpload default: true |
Boolean | Determines if files list is being cleaned up every time user selects files (if value is true), or files list is kept and new files are added to the list (if value is false). | ||||||
retryTimeout default: 1500 |
Number |
When chunk was not uploaded successfully and an error was returned from the server,
the plugin retries to upload the same chunk again.
The value of retryTimeout determines how much time to wait (in milliseconds) between each such try. |
||||||
retryTimes default: 10 |
Number |
When chunk was not uploaded successfully and an error was returned from the server,
the plugin retries to upload the same chunk again.
The value of retryTimes determines how many times to retry uploading the same chunk, before sending showing an error message. |
||||||
rtl default: false |
Boolean |
If true, plugin is displayed in right-to-left direction. Useful for right-to-left
languages such as Hebrew or Arabic.
Demo here. |
||||||
serverScripts
default: Click here |
Object |
Object containing server scripts URLs, for which the plugin uploads the files
to. The object contains the following variables: uploadChunk - Script to upload file chunk, if chunks upload is being used. On last chunk, script should combine all chunks back into a single file. uploadStream - Script to upload file as stream, if stream upload is being used. uploadThroughIframe - Script to upload file using Iframe gateway, if Iframe upload is being used. fileNameVariableName - File name variable to expect back from server, for a successful upload. fileUrlVariableName - File URL variable to expect back from server, for a successful upload. errorVariableName - Error variable to expect back from server, if server script failed. For example:
The server should return JSON (and should support JSONP for cross-domain ability) with array of objects. Each object contains uploaded file data - name and URL - with variable names as defined in serverScripts.fileNameVariableName and serverScripts.fileUrlVariableName. If error occurred on server, object should contain error description, within a varaiable named as serverScripts.errorVariableName value. Example response from server:
SlashUploader can send some additional parameters to the server, of the file meta data (depending on file type and browser capability). These parameters are: • {{file_name}} - File name.
• {{size}} - File size, in KB.
• {{roation}} - Image rotation, in
degrees. Based on camera orientation when the picture was capruted.
• {{duration}} - Media file duration,
in seconds.
• {{width}} - Image or video file
width, in pixels.
• {{height}} - Image or video file
height, in pixels.
• {{extension}} - File extension.
Example use:
Detailed information about how to write server-side files can be seen here. |
||||||
showDetailedErrorFromServer default: true |
Boolean |
Determines if detailed error from server should be seen in case such error occured,
or the general text should be displayed as defined on
errors.uploadFailed parameter.
Demo here. |
||||||
showFocusRect default: false |
Boolean | Determines if a rectangle should be displayed when SlashUploader componenet is focused. | ||||||
status default: idle |
String |
Returns current state of the uploader insance. Can be one of the following values: idle - No files to upload were yet selected. uploading - Files to upload were selected and are currently in upload progress. uploaded - Uploading the files finished succesfuly. canceled - Uploading proccess was canceled. error - There was an error uploading the selected files. Example use:
|
||||||
uploadedFileHtml
default: <a href='{{current_file_path}}' target='_blank'>{{current_file_name}}</a> |
String |
HTML template to display the uploaded files.
Example use:
|
||||||
uploadedFilesPosition |
String |
Determines where uploaded files links should be displayed, relatively to the upload
button.
Avaliable values are: default - Disaply uploaded files beside the button on desktop browsers and below the button on mobile browsers. none - Don't display show uploaded files. below - Display uploaded files beside the button. beside - Display uploaded files below the button. Demo here. |
||||||
uploadedFileTemplate default: null |
Function |
Template callback function to display the uploaded file.
The function receives one parameter - • If groupUploadedFilesResult is set to false (default behavior) - the parameter is an object, contains the file name and URL as returned from server. • If groupUploadedFilesResult is set to true - the parameter is an array of objects, each object contains the file name and URL as returned from server. Example Use:
|
||||||
uploadedFiles default: null |
Array |
Gets or sets the current files list that was uploaded. The array contains list of objects, each object containing file name (parameter file_name) and URL (parameter file_path). This option can be used to receive user's uploaded files data, to pre-define the uploaded files list, or to define at run-time the uploaded files list. For example:
|
||||||
uploadTypePriority default: ["stream", "chunks", "iframe"] |
Array |
Determines the wanted upload type (stream / chunks / iframe) priority the plugin
would try to upload files with.
The avaliable upload types are depend on the user's browser support and abilities. The order in which the plugin would try to upload is the order of the given uploadTypePriority array. For example, if the user's browser is Safari and the upload server script is on another domain - uploading using chunks or stream is not possible. So for the given uploadTypePriority value of ["chunks", "stream", "iframe"], the plugin would upload files using iframe. Example Use:
|
||||||
value default: null |
Array |
Gets or sets the current files list that was uploaded - as described on
uploadedFiles.
For example:
|
Option | Default value | Description | ||
browseText | "Drop files here or click to upload" |
Displayed on: Upload button. When: Before and after upload. Condition: Drag & drop is enabled. |
||
browseTextDropDisabled | "Click to upload" |
Displayed on: Upload button. When: Before and after upload. Condition: Drag & drop is disabled. |
||
cancelText | "Cancel" |
Displayed on: Cancel button. When: While uploading. |
||
dropFilesText | "Drop files here" |
Displayed on: Upload button. When: File is being dragged to the browser window. Condition: Drag & drop is enabled. |
||
errors.invalidFileExtension | "Invalid file extension ({{file_name}})" |
Displayed on: Upload result. When: After selecting files. Condition: One or more of selected files are not valid due to wrong file extension. |
||
errors.invalidFileSize | "Invalid file size ({{file_name}})" |
Displayed on: Upload result. When: After selecting files. Condition: One or more of selected files are not valid due to wrong file size. |
||
errors.networkError | "Network error" |
Displayed on: Upload result. When: After sending upload request to server. Condition: Network error occurred when trying to upload files to server. |
||
errors.parseFailed | "Failed to parse result" |
Displayed on: Upload result. When: After sending upload request to server. Condition: Json returned from server is malformed and not parsable. |
||
errors.unspecifiedError | "Unspecified error" |
Displayed on: Upload result. When: After selecting files or after sending upload request to server. Condition: One or more of selected files didn't passed validation of customValidation, or upload failed on server, and no serverScripts.errorVariableName was returned. |
||
errors.uploadFailed | "Failed to upload" |
Displayed on: Upload result. When: After sending upload request to server. Condition: Upload failed on server. |
||
groupedUploadedFilesHtml | "{{total_files}} files uploaded" |
Displayed on: Upload result. When: After uploading. Condition: File or files were uploaded successfully, and groupUploadedFilesResult is set to true. |
||
uploadedFileHtml | "<a href='{{current_file_path}}' target='_blank'>{{current_file_name}}</a>" |
Displayed on: Upload result. When: After uploading. Condition: File or files were uploaded successfully. Example use:
|
||
uploadingFileByFileText | "Uploading \"{{current_file_name}}\" ({{current_file_index}}/{{total_files}})" |
Displayed on: Upload button. When: While uploading. Conditions: • User selected serveral files to upload at once. • Upload method is "Chunks" or "Stream". |
||
uploadingFileText | "Uploading \"{{current_file_name}}\"" |
Displayed on: Upload button. When: While uploading. Condition: User selected a single file to upload. |
||
uploadingFileTextProgressBar | "Uploading \"{{current_file_name}}\"" |
Displayed on: Progres bar (if progressAnimationType =
"bar"). When: While uploading. Condition: User selected a single file to upload. |
||
uploadingFilesText | "Uploading {{total_files}} files" |
Displayed on: Upload button. When: While uploading. Conditions: • User selected serveral files to upload at once. • Upload method is "through iframe" (due to given settings or lack of browser capability). |
||
uploadingFilesTextProgressBar | "Uploading {{total_files}} files" |
Displayed on: Progres bar (if progressAnimationType =
"bar"). When: While uploading. Condition: User selected multiple files at once to upload. |
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
1
2 3 4 5 6 |
|
Option | Type | Description | ||||
onCanceled default: null |
Function |
Triggered when "Cancel Upload" button was clicked by the user.
For example:
|
||||
onError default: null |
Function |
Triggered when validation error or server error occurred. Parameters: errors - Array of errors, each error contains parameters: • file - File object.
• error - Type of error. can be
invalid_file_extension, invalid_file_size or
upload_failed.
• error_object - Error additional
data.
For example:
|
||||
onFileDeleted default: null |
Function |
Triggered when user clicked the "Delete" icon for a speific file, on "Upload
Results" section. Parameters: • deletedFile - File object of the deleted file. • files - Array containing files objects of the ramining files that weren't deleted. For example:
|
||||
onFilesProgress default: null |
Function |
Triggered during file upload progress. Parameters: • curUploadingFileProgress - Progress of current file being uploaded, from 0 to 1. • curUploadingFileIndex - Index of current file being uploaded, when first is 0. • totalFilesToUpload - Amount of total files selected by the user to upload. For example:
|
||||
onFilesSelected default: null |
Function |
Triggered when user selected files to upload. Notice that if the function defines "continueUpload" argument, the "continueUpload" function must be triggered in order to continue with the uploading proccess. Parameters: • files - Array of files object, with each object containg: • file - Native file object.
• name - File name.
• extension - File extension.
• type - File type.
• size - File size, in KB.
• width - File width in pixels, if
selected file is image or video.
• height - File height in pixels, if
selected file is image or video.
• duration - Media file length in
seconds.
• rotation - Image rotation, based on
the camera orientation when the picture was captured.
• continueUpload - If defined, function must be triggered in
order to continue with the uploading proccess.For example:
|
||||
onFilesUploaded default: null |
Function |
Triggered when files were uploaded and a successful response was retuned from
server. Parameters: files - Array of files object, with each object containg: • file_name - File name.
• file_path - File URL.
For example:
|
Option | Type | Description | ||
cancelUpload | Function |
Cancels the current file upload. For example:
|
||
destroy | Function |
Remove and cleans all created DOM and events. For example:
|