FileUpload
FileUpload provides an easy and integrated way for users to upload multiple files.
Selector
smart-file-upload
Properties
acceptstring | null
Sets or gets the file types that can be submitted to the server via the element. This property corresponds to the 'accept' attribute of the hidden file input which is submitted to the URL specified by the uploadUrl property.
animationAnimation
Sets or gets the animation mode. Animation is disabled when the property is set to 'none'
Default valueadvanced
appendToany
Appends the list with selected files to a new custom container specified by the user. If the value of the property is a string it must represent a valid id of an HTML element inside the DOM that will be used as the new container for the uploaded files list.
autoUploadboolean
Sets or gets whether files will be automatically uploaded after selection.
Default valuefalse
directoryboolean
Allows to upload a directory. Files in all subfolders will be uploaded also. This option is supported only in Firefox and Chrome.
Default valuefalse
disabledboolean
Enables or disables the element.
Default valuefalse
dropZoneany
Defines a custom container that will be used as the new drop zone for file uploads. The dropped files will be added in the fileUpload's list. If 'dropZone' property set to true, the default drop zone inside the element will be used instead. If set to certain id of an HTML element inside the DOM then it will be used as the drop zone.
hideFooterboolean
Hides the footer element and it's contents (Upload All, Pause All and Close All buttons).
Default valuefalse
itemTemplateany
Applies a custom template to the file items that represent the uploaded files.
localestring
Sets or gets the language. Used in conjunction with the property messages.
Default value"en
localizeFormatFunctionany
Callback used to customize the format of the messages that are returned from the Localization Module.
messagesany
Sets the various text values used in the widget. Useful for localization. The localization object has the following fields: browse, pauseFile, cancelFile, uploadFile, pauseAll, cancelAll, uploadAll. It's recommended these messages to be set before element's initialization.
Default value
"en": {
"propertyUnknownType": "'{{name}}' property is with undefined 'type' member!",
"propertyInvalidValue": "Invalid '{{name}}' property value! Actual value: {{actualValue}}, Expected value: {{value}}!",
"propertyInvalidValueType": "Invalid '{{name}}' property value type! Actual type: {{actualType}}, Expected type: {{type}}!",
"elementNotInDOM": "Element does not exist in DOM! Please, add the element to the DOM, before invoking a method.",
"moduleUndefined": "Module is undefined.",
"missingReference": "{{elementType}}: Missing reference to {{files}}.",
"htmlTemplateNotSuported": "{{elementType}}: Browser doesn't support HTMLTemplate elements.",
"invalidTemplate": "{{elementType}}: '{{property}}' property accepts a string that must match the id of an HTMLTemplate element from the DOM.",
"browse": "Browse",
"uploadFile": "Upload File",
"cancelFile": "Cancel File",
"pauseFile": "Pause File",
"uploadAll": "Upload All",
"cancelAll": "Cancel All",
"pauseAll": "Pause All",
"totalFiles": "Total files: ",
"connectionError": "{{elementType}}: File Upload requires connection to the server.",
"wrongItemIndex": "{{elementType}}: There is no file with such an index in the list of uploaded files.",
"tooLongFileName": "{{elementType}}: File name is too long."
}
multipleboolean
Sets or gets whether multiple item uploads are allowed.
Default valuefalse
namestring
Sets or gets the name attribute of the hidden file input which is submitted to the URL specified by the uploadUrl property.
Default value"
readonlyboolean
If the element is readonly, users cannot interact with it.
Default valuefalse
responseHandlerany
Callback that can used to handle various server responses and error codes.
rightToLeftboolean
Sets or gets the value indicating whether the element is aligned to support locales using right-to-left fonts.
Default valuefalse
setHeadersany
Callback function, used to change the headers of the file upload's XHR request.
showProgressboolean
Displays a progress bar at the bottom of each uploaded item to show the progress of the uploading process.
Default valuefalse
themestring
Determines the theme. Theme defines the look of the element
Default value"
uploadUrlstring
Sets or gets the upload URL. This property corresponds to the upload form's action attribute. For example, the uploadUrl property can point to a PHP file, which handles the upload operation on the server-side.
Default value"
unfocusableboolean
If is set to true, the element cannot be focused.
Default valuefalse
validateFileany
Callback used to validate the files immediatelly after their selection. Retuns a boolean value. If the returned value is false, the file is removed from list and a 'validationError is fired.
onfileselected((this: Window, ev: Event) => any) | null
This event is triggered when a file has been selected.
Arguments
evEvent
ev.detailObject
ev.detail.filename - The name of the selected file.
ev.detail.type - The type of the selected file.
ev.detail.size - The size of the selected file.
ev.detail.index - The index of the selected file.
onuploadcanceled((this: Window, ev: Event) => any) | null
This event is triggered when a file upload operation is canceled.
Arguments
evEvent
ev.detailObject
ev.detail.filename - The name of the canceled file.
ev.detail.type - The type of the canceled file.
ev.detail.size - The size of the canceled file.
ev.detail.index - The index of the canceled file.
onuploadcompleted((this: Window, ev: Event) => any) | null
This event is triggered when a file upload operation is completed.
Arguments
evEvent
ev.detailObject
ev.detail.filename - The name of the canceled file.
ev.detail.type - The type of the canceled file.
ev.detail.size - The size of the canceled file.
ev.detail.index - The index of the canceled file.
ev.detail.status - The status of the uploaded file. Whether there was an error or success.
onuploaderror((this: Window, ev: Event) => any) | null
This event is triggered when during the file upload process something happens and upload fails.
Arguments
evEvent
ev.detailObject
ev.detail.filename - The name of the canceled file.
ev.detail.type - The type of the canceled file.
ev.detail.size - The size of the canceled file.
ev.detail.index - The index of the canceled file.
ev.detail.status - The status of the uploaded file. Whether there was an error or success.
onuploadpaused((this: Window, ev: Event) => any) | null
This event is triggered when a file upload operation is paused.
Arguments
evEvent
ev.detailObject
ev.detail.filename - The name of the paused file.
ev.detail.type - The type of the paused file.
ev.detail.size - The size of the paused file.
ev.detail.index - The index of the paused file.
onuploadstarted((this: Window, ev: Event) => any) | null
This event is triggered when a file upload operation is started.
Arguments
evEvent
ev.detailObject
ev.detail.filename - The name of the file that is being uploaded.
ev.detail.type - The type of the file that is being uploaded.
ev.detail.size - The size of the file that is being uploaded.
ev.detail.index - The index of the file that is being uploaded.
onvalidationerror((this: Window, ev: Event) => any) | null
This event is triggered if the validation of a user defined 'validateFile' callback fails.
Arguments
evEvent
ev.detailObject
ev.detail.filename - The name of the file which validation has failed.
ev.detail.type - The type of the file which validation has failed.
ev.detail.size - The size of the file which validation has failed.
Methods
browse(): void
Opens a popup to browse for a file.
cancelAll(): void
Cancels all selected files. The files are removed from the list and their uploading is prevented.
cancelFile( index: number): void
Cancels a selected file. The file is removed from the file list and it's uploading is prevented.
Arguments
indexnumber
Index of the file which will be canceled.
pauseAll(): void
Pauses the uploading of all files. File upload is prevented but the files remain in the file list.
pauseFile( id: number): void
Pauses upload of a file with particular index. File upload is prevented but file ramains in the file list.
Arguments
idnumber
Index of the file which will be paused.
uploadAll(): void
Uploads all selected files.
uploadFile( id: number): void
Uploads a selected file.
Arguments
idnumber
Index of the file which will be uploaded.