JavaScript/jQuery FileUploader Options
See Also
- Configure a Widget: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
abortUpload
Name | Type | Description |
---|---|---|
bytesUploaded |
The count of bytes that is already uploaded to the server. |
|
chunkBlob |
The binary content of the chunk that is uploaded. |
|
chunkCount |
The number of all chunks. |
|
chunkIndex |
The index of the chunk that is uploaded. |
|
customData |
Any custom information that is saved during upload. |
A Promise that is resolved after the upload in aborted. It is a native Promise or a jQuery.Promise when you use jQuery.
accept
The value of this option is passed to the accept attribute of the underlying input element. Thus, the option accepts a MIME type or several types separated by a comma. Refer to the input element documentation for information on available values.
accessKey
The value of this option will be passed to the accesskey
attribute of the HTML element that underlies the widget.
allowCanceling
If this option is set to true, a cancel button is displayed for each selected file.
chunkSize
Specifies the chunk size in bytes. Applies only if uploadMode is "instantly" or "useButtons". Requires a server that can process file chunks.
Set this option to a positive value to enable chunk upload. The widget should be configured as described in the Chunk Upload article. When chunk upload is enabled, the FileUploader sends several multipart/form-data requests with information about the file and chunk. The "chunkMetadata" parameter contains chunk details as a JSON object of the following structure:
{ "FileGuid": string, "FileName": string, "FileType": string, "FileSize": long, "Index": long, // The chunk's index "TotalCount": long, // The file's total chunk count }
See Also
elementAttr
Specifies the attributes to be attached to the widget's root element.
jQuery
$(function(){ $("#fileUploaderContainer").dxFileUploader({ // ... elementAttr: { id: "elementId", class: "class-name" } }); });
Angular
<dx-file-uploader ... [elementAttr]="{ id: 'elementId', class: 'class-name' }"> </dx-file-uploader>
import { DxFileUploaderModule } from "devextreme-angular"; // ... export class AppComponent { // ... } @NgModule({ imports: [ // ... DxFileUploaderModule ], // ... })
Vue
<template> <DxFileUploader ... :element-attr="fileUploaderAttributes"> </DxFileUploader> </template> <script> import DxFileUploader from 'devextreme-vue/file-uploader'; export default { components: { DxFileUploader }, data() { return { fileUploaderAttributes: { id: 'elementId', class: 'class-name' } } } } </script>
React
import React from 'react'; import FileUploader from 'devextreme-react/file-uploader'; class App extends React.Component { fileUploaderAttributes = { id: 'elementId', class: 'class-name' } render() { return ( <FileUploader ... elementAttr={this.fileUploaderAttributes}> </FileUploader> ); } } export default App;
height
This option accepts a value of one of the following types:
Number
The height in pixels.String
A CSS-accepted measurement of height. For example,"55px"
,"80%"
,"inherit"
.Function
A function returning either of the above. For example:JavaScriptheight: function() { return window.innerHeight / 1.5; }
inputAttr
jQuery
$(function(){ $("#fileUploaderContainer").dxFileUploader({ // ... inputAttr: { id: "inputId" } }); });
Angular
<dx-file-uploader ... [inputAttr]="{ id: 'inputId' }"> </dx-file-uploader>
import { DxFileUploaderModule } from "devextreme-angular"; // ... export class AppComponent { // ... } @NgModule({ imports: [ // ... DxFileUploaderModule ], // ... })
ASP.NET MVC Controls
@(Html.DevExtreme().FileUploader() .InputAttr("id", "inputId") // ===== or ===== .InputAttr(new { @id = "inputId" }) // ===== or ===== .InputAttr(new Dictionary<string, object>() { { "id", "inputId" } }) )
@(Html.DevExtreme().FileUploader() _ .InputAttr("id", "inputId") ' ===== or ===== .InputAttr(New With { .id = "inputId" }) ' ===== or ===== .InputAttr(New Dictionary(Of String, Object) From { { "id", "inputId" } }) )
invalidFileExtensionMessage
The text displayed when the extension of the file being uploaded is not an allowed file extension.
invalidMaxFileSizeMessage
The text displayed when the size of the file being uploaded is greater than the maxFileSize.
invalidMinFileSizeMessage
The text displayed when the size of the file being uploaded is less than the minFileSize.
isValid
The FileUploader provides alternative validation options: maxFileSize, minFileSize, and allowedFileExtensions.
maxFileSize
Specifies the maximum file size (in bytes) allowed for uploading. Applies only if uploadMode is "instantly" or "useButtons".
minFileSize
Specifies the minimum file size (in bytes) allowed for uploading. Applies only if uploadMode is "instantly" or "useButtons".
name
Specifies the value passed to the name attribute of the underlying input element. Required to access uploaded files on the server.
See Also
onContentReady
A function that is executed when the widget's content is ready and each time the content is changed.
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
model |
Model data. Available only when using Knockout. |
onDisposing
A function that is executed before the widget is disposed of.
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
model |
Model data. Available only if you use Knockout. |
onInitialized
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onOptionChanged
Name | Type | Description |
---|---|---|
model |
Model data. Available only if you use Knockout. |
|
fullName |
The path to the modified option that includes all parent options. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component |
The widget's instance. |
|
name |
The modified option if it belongs to the first level. Otherwise, the first-level option it is nested into. |
|
value | any |
The modified option's new value. |
onProgress
Name | Type | Description |
---|---|---|
bytesLoaded |
The total count of the uploaded bytes. |
|
bytesTotal |
The total count of bytes in the XMLHttpRequest. |
|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is a dxEvent or a jQuery.Event when you use jQuery. |
file |
An uploaded file. |
|
jQueryEvent |
Use 'event' instead. The jQuery event that caused the handler execution. Deprecated in favor of the event field. |
|
model |
Model data. Available only if Knockout is used. |
|
request |
An XMLHttpRequest for the file. |
|
segmentSize |
The size of the uploaded file segment. |
onUploadAborted
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is a dxEvent or a jQuery.Event when you use jQuery. |
file |
The uploaded file. |
|
jQueryEvent |
Use 'event' instead. The jQuery event that caused the handler execution. Deprecated in favor of the event field. |
|
model |
Model data. Available only if Knockout is used. |
|
request |
Specifies an XMLHttpRequest for the file. |
onUploaded
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is a dxEvent or a jQuery.Event when you use jQuery. |
file |
The uploaded file. |
|
jQueryEvent |
Use 'event' instead. The jQuery event that caused the handler execution. Deprecated in favor of the event field. |
|
model |
Model data. Available only if Knockout is used. |
|
request |
Specifies an XMLHttpRequest for the file. |
onUploadError
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
error | any |
The error that occurred. |
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is a dxEvent or a jQuery.Event when you use jQuery. |
file |
The uploaded file. |
|
jQueryEvent |
Use 'event' instead. The jQuery event that caused the handler execution. Deprecated in favor of the event field. |
|
model |
Model data. Available only if Knockout is used. |
|
request |
Specifies an XMLHttpRequest for the file. |
The following code shows how you can handle a network error.
jQuery
$(function(){ $("#fileUploader").dxFileUploader({ // ... onUploadError: function(e){ var xhttp = e.request; if (xhttp.readyState == 4 && xhttp.status == 0) { console.log("Connection refused."); } } }); });
Angular
export class AppComponent { handleNetworkError (e) { var xhttp = e.request; if (xhttp.readyState == 4 && xhttp.status == 0) { console.log("Connection refused."); } } }
<dx-file-uploader ... (onUploadError)="handleNetworkError($event)"> </dx-fileUploader>
onUploadStarted
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is a dxEvent or a jQuery.Event when you use jQuery. |
file |
The uploaded file. |
|
jQueryEvent |
Use 'event' instead. The jQuery event that caused the handler execution. Deprecated in favor of the event field. |
|
model |
Model data. Available only if Knockout is used. |
|
request |
Specifies an XMLHttpRequest for the file. |
onValueChanged
Name | Type | Description |
---|---|---|
value |
Newly selected files. |
|
previousValue |
Previously selected files. |
|
model |
Model data. Available only if Knockout is used. |
|
jQueryEvent |
Use 'event' instead. The jQuery event that caused the handler execution. Deprecated in favor of the event field. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is a dxEvent or a jQuery.Event when you use jQuery. This field is undefined if the value is changed programmatically. |
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component |
The widget's instance. |
readyToUploadMessage
This option makes sense only if the uploadMode option is set to "useButtons".
rtlEnabled
When this option is set to true, the widget text flows from right to left, and the layout of elements is reversed. To switch the entire application/site to the right-to-left representation, assign true to the rtlEnabled field of the object passed to the DevExpress.config(config) method.
DevExpress.config({ rtlEnabled: true });
See Also
- Right-to-Left Support Demo: DataGrid | Navigation Widgets | Editors
tabIndex
The value of this option will be passed to the tabindex
attribute of the HTML element that underlies the widget.
uploadButtonText
The option makes sense only if the uploadMode option is set to "useButtons" or "instantly".
uploadChunk
Name | Type | Description |
---|---|---|
bytesUploaded |
The count of bytes that is already uploaded to the server. |
|
chunkBlob |
The binary content of the chunk that is uploaded. |
|
chunkCount |
The number of all chunks. |
|
chunkIndex |
The index of the chunk that is uploaded. |
|
customData |
Any custom information that is saved during the upload. |
A Promise that is resolved after the chunk is uploaded. It is a native Promise or a jQuery.Promise when you use jQuery.
uploadedMessage
The option makes sense only if the uploadMode option is set to "useButtons" or "instantly".
uploadFailedMessage
The option makes sense only if the uploadMode option is set to "useButtons" or "instantly".
uploadFile
A Promise that is resolved after the file is uploaded. It is a native Promise or a jQuery.Promise when you use jQuery.
A Promise that is resolved after the file is uploaded. It is a native Promise or a jQuery.Promise when you use jQuery.
uploadMethod
The option makes sense only if the uploadMode option is set to "useButtons" or "instantly".
Use the UploadHttpMethod
enum to specify this option when the widget is used as an ASP.NET MVC 5 Control or a DevExtreme-Based ASP.NET Core Control. This enum accepts the following values: POST
and PUT
.
uploadMode
Depending on the uploadMode, the FileUploader widget uses an HTML form or a FormData interface with a series of Ajax requests to upload files. The uploadMode option accepts one of the following values:
"instantly" (default)
Ajax upload. Files are uploaded after they are selected."useButtons"
Ajax upload. Files are uploaded after a user clicks the Upload button."useForm"
HTML form upload. Files are uploaded when the HTML form is submitted.
Use the FileUploadMode
enum to specify this option when the widget is used as an ASP.NET MVC 5 Control or a DevExtreme-Based ASP.NET Core Control. This enum accepts the following values: Instantly
, UseButtons
, and UseForm
.
See Also
uploadUrl
The option makes sense only if the uploadMode option is set to "useButtons" or "instantly".
validationError
Information on the broken validation rule. Contains the first item from the validationErrors array.
value
Specifies a File instance representing the selected file. Read-only when uploadMode is "useForm".
width
This option accepts a value of one of the following types:
Number
The width in pixels.String
A CSS-accepted measurement of width. For example,"55px"
,"80%"
,"auto"
,"inherit"
.Function
A function returning either of the above. For example:JavaScriptwidth: function() { return window.innerWidth / 1.5; }
If you have technical questions, please create a support ticket in the DevExpress Support Center.