Uploader

The Uploader control allows a user to upload documents, pictures and other files types.

Properties

allowedExtensions String

Specifies a comma separated list of extensions that can be uploaded, for example ".webp,.png".

Default: ""

asyncSettings AsyncSettingsModel

Specifies the save and remove URL to perform the upload operations in the server asynchronously.

Default: { saveUrl: "", removeUrl: "" }

autoUpload Boolean

Specifies whether to auto upload the files once they are added to the upload queue. If files need to be manipulated before upload, then this should be false.

Default: true

buttons ButtonSettingsModel

Specifies the text values or localization values for the buttons that appear in the uploader. The buttons “upload” and “clear” will not be visible in the file list when autoUpload property is true.

Default: { browse : 'Browse...', clear: 'Clear', upload: 'Upload' }

cssClass String

Specifies CSS classes to customize the appearance of the control.

Default: ""

directoryUpload Boolean

Specifies whether the folder of files can be browsed in the uploader control.

Default: false

dropArea String HTMLElement

Specifies the drop area target to handle the drag-and-dropping of a file into the uploader.

Default: null

dropEffect DropEffect

Specifies the drag operation effect used for the uploader control.

Default: Default

enabled Boolean

Specifies whether the control is enabled or disabled, disabled will prevent user interaction.

Default: true

enableHtmlSanitizer Boolean

Specifies whether to allow the rendering of untrusted HTML and JavaScript values withing the control. When true, any untrusted strings or scripts will be remote before rendering.

Default: true

enableRtl Boolean

Specifies whether to render the control in right to left direction.

Default: false

enableState Boolean

Specifies whether to persist the state of the control between page loads.

The following properties will be saved to state.
  • filesData

Default: false

files FilesModel[]

Specifies a list of files that will be preloaded on the rendering of uploader control.

Default: []

htmlAttributes {:}

Specifies additional HTML attributes, such as title, styles, class, id, and name, in a key-value pair format that will be appended to the HTML element. If both the property and equivalent HTML attributes are configured, then the control overrides the property value with the HTML attributes.

Default: {}

locale String

Specifies the culture and localization value for this control, overriding the globally defined value.

Default: en-US

maxFileSize Number

Specifies the maximum allowed file size in bytes that will be allowed to be uploaded.

Default: 30000000

minFileSize Number

Specifies the minimum allowed file size in bytes that will be allowed to be uploaded.

Default: 0

multiple Boolean

Specifies whether multiple files can be browsed or dropped simultaneously in the uploader control.

Default: true

sequentialUpload Boolean

Specifies whether to process multiple files simultaneously or upload files one after the other.

Default: false

showFileList Boolean

Specifies whether the file list should be rendered.

Default: true

template String Function

Specifies a template used to customize the appearance of the uploader.

Default: null

Methods

addEventListener

Attaches an event handler to a specified element. This method allows you to set up a function that will be called whenever the specified event is delivered to the target element.

Parameter Type Description
eventName String A string value that specifies the name of the event.
handler Function Specifies the function to run when the event is triggered.

Returns: Void

appendTo

Appends the control to the specified HTML element.

Parameter Type Description
selector String HTMLElement The select to a specified HTML element or an HTML element where the control will be appended to.

Returns: Void

bytesToSize

Converts bytes to kilobytes/megabytes depending on the binary prefix.

Parameter Type Description
bytes Number Specifies the file size in bytes to be converted.

Returns: Void

cancel

Stops a chuck upload currently in-progress based on the given file info.

Parameter Type Description
fileInfo FileInfo[] Specifies the file info to cancel the upload.

Returns: Void

clearAll

Clears all the files from the file list that have been added to the upload queue.

Returns: Void

createFileList

Create a file list from the given file info object.

Parameter Type Description
fileInfo FileInfo[] Specifies an array of file info objects to create the file list for.

Returns: Void

dataBind

Applies all pending property changes to the control.

Returns: Void

destroy

Destroys the Aware instance, detaches all related events, removes attributes, css classes and restores the root element.

Returns: Void

getFilesData

Gets the file info object for the given index within the file list.

Parameter Type Description
fileInfo Number Specifies the index to get the file info object for, if no value is passed then the current selected file info is returned.

Returns: FileInfo[]

getLocalData

Gets the current properties values for the accordion that will be persisted to the state.

Returns: String

getRootElement

Gets the root element of the control.

Returns: HTMLElement

getStateData

Gets the current persisted state data for the control.

Returns: String

pause

Pauses the progress if the current chunk upload based on the given file info object.

Parameter Type Description
fileInfo FileInfo FileInfo[] Specifies the file info object to pause from uploading.

Returns: Void

refresh

Applies all pending property changes to the accordion and re-renders the control.

Returns: Void

remove

Calls the remove action at the remove url property to remove the file from the server. To remove all files, pass empty arguments.

Parameter Type Description
fileInfo FileInfo FileInfo[] Specifies the file info object to pause from uploading.
customTemplate Boolean Specifies whether the control rendering is using a custom template or not.
postRawFile Boolean Specifies whether just the file name is sent, false, or the raw file, true, is sent in the request.

Returns: Void

removeEventListener

Removes the attached event handler for the specified event listener.

Parameter Type Description
eventName String A string value that specifies the name of the event to be removed.
handler Function Specifies the function to be removed.

Returns: Void

resume

Resumes a chunk upload previously paused based on the file info object.

Parameter Type Description
fileInfo FileInfo FileInfo[] Specifies the file info object or an array of file info objects to resume the paused file.

Returns: Void

retry

Retries a canceled or failed file upload based on the file info object.

Parameter Type Description
fileInfo FileInfo FileInfo[] Specifies the file info object or an array of file info objects to retry the canceled or failed file.
fromCanceledStage Boolean Specifies whether to retry from a canceled stage, true, or to retry from initial stage, false.

Returns: Void

sortFileList

Sorts the file info objects based on the file name property.

Parameter Type Description
fileList FileList Specifies an array of file info objects to sort.

Returns: FileList[]

upload

Calls the save action at the save url property to upload the given file info objects to the server. If no value is passed, then the selected file info object will be uploaded.

Parameter Type Description
fileInfo FileInfo FileInfo[] Specifies a file info object or an array of file info objects that should be uploaded.

Returns: Void

Events

actionComplete EmitType<ChunkSuccessEventArgs>

Event callback that is raised after files have been upload successfully or failed to server.

beforeRemove EmitType<ChunkSuccessEventArgs>

Event callback that is raised before the removing process starts allowing for additional parameter to be added to the HTTP request.

beforeUpload EmitType<BeforeUploadEventArgs>

Event callback that is raised before the upload process starts allowing for additional parameter to be added to the HTTP request.

canceling EmitType<ChunkSuccessEventArgs>

Event callback that is raised when canceling a file upload.

change EmitType<Object>

Event callback that is raised when changes have occurred in the uploaded file list by selecting or dropping files.

chunkFailure EmitType<ChunkSuccessEventArgs>

Event callback that is raised when a chunk file upload fails.

chunkSuccess EmitType<ChunkSuccessEventArgs>

Event callback that is raised when a chunk file upload is successful.

chunkUploading EmitType<UploadingEventArgs>

Event callback that is raised when every chunk upload is started allowing for additional parameter to the added to the HTTP request.

clearing EmitType<ClearingEventArgs>

Event callback that is raised before the clearing of the files from the file list when the clear button is clicked.

created EmitType<CreatedEventArgs>

Event callback that is raised when the control has been created.

destroyed EmitType<Object>

Event callback that is raised when the control has been destroyed.

failure EmitType<FailureEventArgs>

Event callback that is raised when an AJAX request fails on uploading or removing files.

pausing EmitType<PauseResumeEventArgs>

Event callback that is raised when pausing a chunk file upload.

progress EmitType<ProgressEventArgs>

Event callback that is raised when uploading a file to the server using an AJAX request.

removing EmitType<RemovingEventArgs>

Event callback that is raised before the removing of a file is started.

rendering EmitType<RenderingEventArgs>

Event callback that is raised before the rendering of each file item in the file list.

resuming EmitType<PauseResumeEventArgs>

Event callback that is raised when resuming a paused chunk file upload.

selected EmitType<SelectedEventArgs>

Event callback that is raised when selecting or dropping files to the upload queue.

success EmitType<SuccessEventArgs>

Event callback that is raised when the AJAX request gets a success on uploading files or removing files.

uploading EmitType<UploadingEventArgs>

Event callback that is raised when uploading has begun allowing for additional parameter to the added to the HTTP request.