Configuration

An object defining configuration options for the FileUploader widget.

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

Show Example:
AngularJS
Knockout
jQuery

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'.

buttonText

Deprecated

Use the selectButtonText option instead.

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: {}

You can configure this option in an ASP.NET MVC Control as follows:

Razor C#
Razor VB
@(Html.DevExtreme().WidgetName()
    .ElementAttr("class", "class-name")
    // ===== or =====
    .ElementAttr(new {
        @id = "elementId",
        @class = "class-name"
    })
    // ===== or =====
    .ElementAttr(new Dictionary<string, object>() {
        { "id", "elementId" },
        { "class", "class-name" }
    })

)
@(Html.DevExtreme().WidgetName() _
    .ElementAttr("class", "class-name")
    ' ===== or =====
    .ElementAttr(New With {
        .id = "elementId",
        .class = "class-name"
    })
    ' ===== or =====
    .ElementAttr(New Dictionary(Of String, Object) From {
        { "id", "elementId" },
        { "class", "class-name" }
    })
)

focusStateEnabled

Specifies whether the widget can be focused using keyboard navigation.

Type:

Boolean

Default Value: false
Default for generic: true

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 of the widget in pixels.

  • String
    A CSS-accepted measurement of height. For example, "55px", "80%", "auto", "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

isValid

Specifies whether the editor's value is valid.

Type:

Boolean

Default Value: true

In Knockout apps, you may need to inform a user about an error that occurred during the validation of a view model field. For this purpose, set the editor's isValid option to the isValid value of the dxValidator that validates this field. To show an error message, set the editor's validationError option to the dxValidator's validationError value.

JavaScript
var editorValue = ko.observable("").extend({
    dxValidator: {
        validationRules: [{
            type: 'required',
            message: 'Specify this value'
        }]
    }
});
var viewModel = {
    editorOptions: {
        value: editorValue,
        isValid: editorValue.dxValidator.isValid,
        validationError: editorValue.dxValidator.validationError
    }
};

The editor's isValid and validationError options should also be specified when using a custom validation engine. In this instance, the validation result will be displayed for the editor by the means of the DevExtreme Validation UI.

See Also

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'

Show Example:
AngularJS
Knockout
jQuery

multiple

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

Type:

Boolean

Default Value: false

Show Example:
AngularJS
Knockout
jQuery

name

Specifies the value passed to the name attribute of the underlying input element.

Type:

String

Default Value: ''

onContentReady

A handler for the contentReady event. Executed when the widget's content is ready. This handler may be executed multiple times during the widget's lifetime depending on the number of times its content changes.

Type:

function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Object

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container.

model:

Object

The model data. Available only when using Knockout.

Default Value: null

onDisposing

A handler for the disposing event. Executed when the widget is removed from the DOM using the remove(), empty(), or html() jQuery methods only.

Type:

function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Object

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container.

model:

Object

The model data. Available only if you use Knockout.

Default Value: null

onInitialized

A handler for the initialized event. Executed only once, after the widget is initialized.

Type:

function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Object

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container.

Default Value: null

You cannot access widget elements in this handler because it is executed before they are ready. Use the onContentReady handler instead.

onOptionChanged

A handler for the optionChanged event. Executed after an option of the widget is changed.

Type:

function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Object

The widget's instance.

name:

String

The option's short name.

fullName:

String

The option's full name.

value: any

The option's new value.

element:

Element (jQuery or HTML)

The widget's container.

model:

Object

The model data. Available only if you use Knockout.

Default Value: null

onProgress

A handler for the uploaded event.

Type:

function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Object

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container.

model:

Object

The model data. Available only if Knockout is used.

file:

File

An uploaded file.

segmentSize:

Number

The size of the uploaded file segment.

bytesLoaded:

Number

The total count of the uploaded bytes.

bytesTotal:

Number

The total count of bytes in the XMLHttpRequest.

jQueryEvent:

jQuery.Event

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

event:

Event (jQuery or dxEvent)

The event that caused the handler execution. It is a dxEvent or a jQuery.Event when you use jQuery.

An XMLHttpRequest for the file.

Default Value: null

Assign a function to perform a custom action when a segment of a file has been uploaded.

onUploadAborted

A handler for the uploadAborted event.

Type:

function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Object

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container.

model:

Object

The model data. Available only if Knockout is used.

file:

Object

The uploaded file.

jQueryEvent:

jQuery.Event

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

event:

Event (jQuery or dxEvent)

The event that caused the handler execution. It is a dxEvent or a jQuery.Event when you use jQuery.

Specifies an XMLHttpRequest for the file.

Default Value: null

Assign a function to perform a custom action when file uploading has been aborted.

onUploaded

A handler for the uploaded event.

Type:

function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Object

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container.

model:

Object

The model data. Available only if Knockout is used.

file:

File

The uploaded file.

jQueryEvent:

jQuery.Event

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

event:

Event (jQuery or dxEvent)

The event that caused the handler execution. It is a dxEvent or a jQuery.Event when you use jQuery.

Specifies an XMLHttpRequest for the file.

Default Value: null

Assign a function to perform a custom action when a file has been uploaded.

onUploadError

A handler for the uploadError event.

Type:

function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Object

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container.

model:

Object

The model data. Available only if Knockout is used.

file:

File

The uploaded file.

jQueryEvent:

jQuery.Event

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

event:

Event (jQuery or dxEvent)

The event that caused the handler execution. It is a dxEvent or a jQuery.Event when you use jQuery.

Specifies an XMLHttpRequest for the file.

Default Value: null

Assign a function to perform a custom action when an error has occurred during uploading.

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 handler for the uploadStarted event.

Type:

function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Object

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container.

model:

Object

The model data. Available only if Knockout is used.

file:

File

The uploaded file.

jQueryEvent:

jQuery.Event

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

event:

Event (jQuery or dxEvent)

The event that caused the handler execution. It is a dxEvent or a jQuery.Event when you use jQuery.

Specifies an XMLHttpRequest for the file.

Default Value: null

Assign a function to perform a custom action when file uploading is started.

onValueChanged

A handler for the valueChanged event.

Type:

function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Object

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container.

model:

Object

The model data. Available only if Knockout is used.

value:

Array<File>

Newly selected files.

previousValue:

Array<File>

Previously selected files.

jQueryEvent:

jQuery.Event

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

event:

Event (jQuery or dxEvent)

The event that caused the handler execution. It is a dxEvent or a jQuery.Event when you use jQuery.

Default Value: null

Assign a function to perform a custom action when a file or several files are added to or removed from selection.

progress

Gets the current progress in percentages.

Type:

Number

Default Value: 0

readOnly

A Boolean value specifying whether or not the widget 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
});

selectButtonText

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

Type:

String

Default Value: 'Select File'

Show Example:
AngularJS
Knockout
jQuery

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".

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".

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".

When using the widget as an ASP.NET MVC Control, specify this option using the UploadHttpMethod enum. This enum accepts the following values: POST and PUT.

uploadMode

Specifies how the widget uploads files.

Type:

String

Default Value: 'instantly'
Default for Internet Explorer 9 and 10: 'useForm'
Accepted Values: 'instantly' | 'useButtons' | 'useForm'

The option accepts the following values.

  • instantly
    Starts uploading instantly as files are selected.

  • useButtons
    Starts uploading when a user clicks the "Upload" button.

  • useForm
    Uploads the specified files when the submit button of the current form is clicked. In this case, the FileUploader widget should be enclosed in the form element.

When using the widget as an ASP.NET MVC Control, specify this option using the FileUploadMode enum. This enum accepts the following values: Instantly, UseButtons and UseForm.

View Demo

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".

validationError

Specifies information on the validation error when using a custom validation engine. Should be changed at runtime along with the isValid option.

Type:

Object

Default Value: undefined

value

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

Type:

Array<File>

Default Value: []

values

Deprecated

Use the value option instead.

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 of the widget 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;
    }