All docs
V19.2
24.2
The page you are viewing does not exist in version 24.2.
24.1
The page you are viewing does not exist in version 24.1.
23.2
The page you are viewing does not exist in version 23.2.
23.1
The page you are viewing does not exist in version 23.1.
22.2
The page you are viewing does not exist in version 22.2.
22.1
The page you are viewing does not exist in version 22.1.
21.2
The page you are viewing does not exist in version 21.2.
21.1
The page you are viewing does not exist in version 21.1.
20.2
The page you are viewing does not exist in version 20.2.
20.1
The page you are viewing does not exist in version 20.1.
19.2
19.1
18.2
18.1
17.2
Box
Map
Vue
A newer version of this page is available. Switch to the current version.

JavaScript/jQuery FileUploader Options

An object defining configuration options for the FileUploader widget.

See Also

abortUpload

A function that cancels the file upload.

Type:

Function

Function parameters:
file:

File

The file that is uploaded.

uploadInfo:

Object

Information about the file upload session.

Object structure:
Name Type Description
bytesUploaded

Number

The count of bytes that is already uploaded to the server.

chunkBlob

BLOB

The binary content of the chunk that is uploaded.

chunkCount

Number

The number of all chunks.

chunkIndex

Number

The index of the chunk that is uploaded.

customData

Object

Any custom information that is saved during upload.

Return Value:

Promise<any> (jQuery or native)

| any

A Promise that is resolved after the upload in aborted. It is a native Promise or a jQuery.Promise when you use jQuery.

jQuery
index.js
$(function() {
    $("#file-uploader").dxFileUploader({
        multiple: true,
        chunkSize: 200000,
        abortUpload: function(file, uploadInfo) {
            // your code
        }
    });      
});

accept

Specifies a file type or several types accepted by the widget.

Type:

String

Default Value: ''

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.

View Demo

accessKey

Specifies the shortcut key that sets focus on the widget.

Type:

String

Default Value: null

The value of this option will be passed to the accesskey attribute of the HTML element that underlies the widget.

activeStateEnabled

Specifies whether or not the widget changes its state when interacting with a user.

Type:

Boolean

Default Value: false

This option is used when the widget is displayed on a platform whose guidelines include the active state change for widgets.

allowCanceling

Specifies if an end user can remove a file from the selection and interrupt uploading.

Type:

Boolean

Default Value: true

If this option is set to true, a cancel button is displayed for each selected file.

NOTE
This option applies only if the uploadMode is not set to "useForm".

allowedFileExtensions

Restricts file extensions that can be uploaded to the server.

Type:

Array<String>

Default Value: []

chunkSize

Specifies the chunk size in bytes. Applies only if uploadMode is "instantly" or "useButtons". Requires a server that can process file chunks.

Type:

Number

Default Value: 0

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
}

View Demo

See Also

disabled

Specifies whether the widget responds to user interaction.

Type:

Boolean

Default Value: false

elementAttr

Specifies the attributes to be attached to the widget's root element.

Type:

Object

Default Value: {}

jQuery
$(function(){
    $("#fileUploaderContainer").dxFileUploader({
        // ...
        elementAttr: {
            id: "elementId",
            class: "class-name"
        }
    });
});
Angular
HTML
TypeScript
<dx-file-uploader ...
    [elementAttr]="{ id: 'elementId', class: 'class-name' }">
</dx-file-uploader>
import { DxFileUploaderModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxFileUploaderModule
    ],
    // ...
})
Vue
App.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
App.js
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;

focusStateEnabled

Specifies whether the widget can be focused using keyboard navigation.

Type:

Boolean

Default Value: true (desktop)

height

Specifies the widget's height.

Type:

Number

|

String

|

Function

Return Value:

Number

|

String

The widget's height.

Default Value: undefined

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:

    JavaScript
    height: function() {
        return window.innerHeight / 1.5;
    }

hint

Specifies text for a hint that appears when a user pauses on the widget.

Type:

String

Default Value: undefined

hoverStateEnabled

Specifies whether the widget changes its state when a user pauses on it.

Type:

Boolean

Default Value: false

inputAttr

Specifies the attributes to be passed on to the underlying <input> element of the file type.

Type:

Object

Default Value: {}

jQuery
$(function(){
    $("#fileUploaderContainer").dxFileUploader({
        // ...
        inputAttr: {
            id: "inputId"
        }
    });
});
Angular
HTML
TypeScript
<dx-file-uploader ...
    [inputAttr]="{ id: 'inputId' }">
</dx-file-uploader>
import { DxFileUploaderModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxFileUploaderModule
    ],
    // ...
})
ASP.NET MVC Controls
Razor C#
Razor VB
@(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.

Type:

String

Default Value: 'File type is not allowed'

invalidMaxFileSizeMessage

The text displayed when the size of the file being uploaded is greater than the maxFileSize.

Type:

String

Default Value: 'File is too large'

invalidMinFileSizeMessage

The text displayed when the size of the file being uploaded is less than the minFileSize.

Type:

String

Default Value: 'File is too small'

isValid

Specifies or indicates whether the editor's value is valid.

Type:

Boolean

Default Value: true

The FileUploader provides alternative validation options: maxFileSize, minFileSize, and allowedFileExtensions.

labelText

Specifies the text displayed on the area to which an end-user can drop a file.

Type:

String

Default Value: 'or Drop file here'

maxFileSize

Specifies the maximum file size (in bytes) allowed for uploading. Applies only if uploadMode is "instantly" or "useButtons".

Type:

Number

Default Value: 0

minFileSize

Specifies the minimum file size (in bytes) allowed for uploading. Applies only if uploadMode is "instantly" or "useButtons".

Type:

Number

Default Value: 0

multiple

Specifies whether the widget enables an end-user to select a single file or multiple files.

Type:

Boolean

Default Value: false

name

Specifies the value passed to the name attribute of the underlying input element. Required to access uploaded files on the server.

Type:

String

Default Value: 'files[]'

NOTE
This option's value should end with square brackets if the uploadMode is "useForm". Refer to the Upload Mode topic for an example.
See Also

onContentReady

A function that is executed when the widget's content is ready and each time the content is changed.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FileUploader

The widget's instance.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model

Object

Model data. Available only when using Knockout.

Default Value: null

onDisposing

A function that is executed before the widget is disposed of.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FileUploader

The widget's instance.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model

Object

Model data. Available only if you use Knockout.

Default Value: null

onInitialized

A function used in JavaScript frameworks to save the widget instance.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FileUploader

The widget's instance.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

Default Value: null

See Also

onOptionChanged

A function that is executed after a widget option is changed.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
model

Object

Model data. Available only if you use Knockout.

fullName

String

The path to the modified option that includes all parent options.

element

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

component

FileUploader

The widget's instance.

name

String

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.

Default Value: null

onProgress

A function that is executed when a file segment is uploaded.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
bytesLoaded

Number

The total count of the uploaded bytes.

bytesTotal

Number

The total count of bytes in the XMLHttpRequest.

component

FileUploader

The widget's instance.

element

HTMLElement | jQuery

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

File

An uploaded file.

jQueryEvent

jQuery.Event

Use 'event' instead.

The jQuery event that caused the handler execution. Deprecated in favor of the event field.

model

Object

Model data. Available only if Knockout is used.

request

XMLHttpRequest Object

An XMLHttpRequest for the file.

segmentSize

Number

The size of the uploaded file segment.

Default Value: null

onUploadAborted

A function that is executed when the file upload is aborted.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FileUploader

The widget's instance.

element

HTMLElement | jQuery

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

File

The uploaded file.

jQueryEvent

jQuery.Event

Use 'event' instead.

The jQuery event that caused the handler execution. Deprecated in favor of the event field.

model

Object

Model data. Available only if Knockout is used.

request

XMLHttpRequest Object

Specifies an XMLHttpRequest for the file.

Default Value: null

onUploaded

A function that is executed when a file is successfully uploaded.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FileUploader

The widget's instance.

element

HTMLElement | jQuery

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

File

The uploaded file.

jQueryEvent

jQuery.Event

Use 'event' instead.

The jQuery event that caused the handler execution. Deprecated in favor of the event field.

model

Object

Model data. Available only if Knockout is used.

request

XMLHttpRequest Object

Specifies an XMLHttpRequest for the file.

Default Value: null

onUploadError

A function that is executed when an error occurs during the file upload.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FileUploader

The widget's instance.

element

HTMLElement | jQuery

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

File

The uploaded file.

jQueryEvent

jQuery.Event

Use 'event' instead.

The jQuery event that caused the handler execution. Deprecated in favor of the event field.

model

Object

Model data. Available only if Knockout is used.

request

XMLHttpRequest Object

Specifies an XMLHttpRequest for the file.

Default Value: null

The following code shows how you can handle a network error.

jQuery
JavaScript
$(function(){
    $("#fileUploader").dxFileUploader({
        // ...
        onUploadError: function(e){
            var xhttp = e.request;
            if (xhttp.readyState == 4 && xhttp.status == 0) {
                console.log("Connection refused.");
            }
        }
    });
});
Angular
TypeScript
HTML
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

A function that is executed when the file upload is started.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FileUploader

The widget's instance.

element

HTMLElement | jQuery

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

File

The uploaded file.

jQueryEvent

jQuery.Event

Use 'event' instead.

The jQuery event that caused the handler execution. Deprecated in favor of the event field.

model

Object

Model data. Available only if Knockout is used.

request

XMLHttpRequest Object

Specifies an XMLHttpRequest for the file.

Default Value: null

onValueChanged

A function that is executed when one or several files are added to or removed from the selection.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
value

Array<File>

Newly selected files.

previousValue

Array<File>

Previously selected files.

model

Object

Model data. Available only if Knockout is used.

jQueryEvent

jQuery.Event

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

HTMLElement | jQuery

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

component

FileUploader

The widget's instance.

Default Value: null

progress

Gets the current progress in percentages.

Type:

Number

Default Value: 0

readOnly

Specifies whether the editor is read-only.

Type:

Boolean

Default Value: false

readyToUploadMessage

The message displayed by the widget when it is ready to upload the specified files.

Type:

String

Default Value: 'Ready to upload'

This option makes sense only if the uploadMode option is set to "useButtons".

rtlEnabled

Switches the widget to a right-to-left representation.

Type:

Boolean

Default Value: false

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.

JavaScript
DevExpress.config({
    rtlEnabled: true
});
See Also

selectButtonText

The text displayed on the button that opens the file browser.

Type:

String

Default Value: 'Select File'

showFileList

Specifies whether or not the widget displays the list of selected files.

Type:

Boolean

Default Value: true

tabIndex

Specifies the number of the element when the Tab key is used for navigating.

Type:

Number

Default Value: 0

The value of this option will be passed to the tabindex attribute of the HTML element that underlies the widget.

uploadButtonText

The text displayed on the button that starts uploading.

Type:

String

Default Value: 'Upload'

The option makes sense only if the uploadMode option is set to "useButtons" or "instantly".

uploadChunk

A function that uploads a file in chunks.

Type:

Function

Function parameters:
file:

File

The file that is uploaded.

uploadInfo:

Object

Information about the file upload session.

Object structure:
Name Type Description
bytesUploaded

Number

The count of bytes that is already uploaded to the server.

chunkBlob

BLOB

The binary content of the chunk that is uploaded.

chunkCount

Number

The number of all chunks.

chunkIndex

Number

The index of the chunk that is uploaded.

customData

Object

Any custom information that is saved during the upload.

Return Value:

Promise<any> (jQuery or native)

| any

A Promise that is resolved after the chunk is uploaded. It is a native Promise or a jQuery.Promise when you use jQuery.

jQuery
index.js
$(function() {
    $("#file-uploader").dxFileUploader({
        multiple: true,
        chunkSize: 200000,
        uploadChunk: function(file, uploadInfo) {
            // your code
        }
    });      
});

uploadedMessage

The message displayed by the widget when uploading is finished.

Type:

String

Default Value: 'Uploaded'

The option makes sense only if the uploadMode option is set to "useButtons" or "instantly".

uploadFailedMessage

The message displayed by the widget on uploading failure.

Type:

String

Default Value: 'Upload failed'

The option makes sense only if the uploadMode option is set to "useButtons" or "instantly".

uploadFile

A function that uploads a file.

Type:

Function

Event Handler Arguments:
file:

File

The file that is uploaded.

progressCallback:

Function

A function that you should call to notify the widget about the file upload progress.

Return Value:

Promise<any> (jQuery or native)

| any

A Promise that is resolved after the file is uploaded. It is a native Promise or a jQuery.Promise when you use jQuery.

Return Value:

Promise<any> (jQuery or native)

| any

A Promise that is resolved after the file is uploaded. It is a native Promise or a jQuery.Promise when you use jQuery.

jQuery
index.js
$(function() {
    $("#file-uploader").dxFileUploader({
        multiple: true,
        uploadFile: function(file, progressCallback) {
            // your code
            progressCallback(100);
            // ...
            progressCallback(200);
            // ...
        }
    });         
});

uploadHeaders

Specifies headers for the upload request.

Type:

Object

Default Value: {}

uploadMethod

Specifies the method for the upload request.

Type:

String

Default Value: 'POST'
Accepted Values: 'POST' | 'PUT'

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

Specifies how the widget uploads files.

Type:

String

Default Value: 'instantly'
Accepted Values: 'instantly' | 'useButtons' | 'useForm'

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.

View Demo

See Also

uploadUrl

Specifies a target Url for the upload request.

Type:

String

Default Value: '/'

The option makes sense only if the uploadMode option is set to "useButtons" or "instantly".

View Demo

validationError

Information on the broken validation rule. Contains the first item from the validationErrors array.

Type:

Object

Default Value: null

See Also

validationErrors

An array of the validation rules that failed.

Type:

Array<Object>

Default Value: null

validationStatus

Indicates or specifies the current validation status.

Type:

String

Default Value: 'valid'
Accepted Values: 'valid' | 'invalid' | 'pending'

The following table illustrates the validation status indicators:

validationStatus Indicator
"pending" DevExtreme editor validation status: pending
"valid" DevExtreme editor validation status: valid
"invalid" DevExtreme editor validation status: invalid

value

Specifies a File instance representing the selected file. Read-only when uploadMode is "useForm".

Type:

Array<File>

Default Value: []
Raised Events: onValueChanged

visible

Specifies whether the widget is visible.

Type:

Boolean

Default Value: true

width

Specifies the widget's width.

Type:

Number

|

String

|

Function

Return Value:

Number

|

String

The widget's width.

Default Value: undefined

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:

    JavaScript
    width: function() {
        return window.innerWidth / 1.5;
    }