Angular FileUploader Properties

An object defining configuration properties for the FileUploader UI component.

abortUpload

A function that cancels the file upload.

Type:

Function

Function parameters:
file:

File

The file that is uploaded.

uploadInfo?:

UploadInfo

Information about the file upload session.

Return Value:

Promise<any> (jQuery or native)

| any

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

jQuery
index.js
$(function() {
    $("#file-uploader").dxFileUploader({
        abortUpload: function(file, uploadInfo) {
            // your code
        }
    });      
});
Angular
app.component.html
app.component.ts
app.module.ts
<dx-file-uploader ...
    [abortUpload]="fileUploader_abortUpload">
</dx-file-uploader>
import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent {
    // Uncomment the following lines if the function should be executed in the component's context
    // constructor() {
    //     this.fileUploader_abortUpload = this.fileUploader_abortUpload.bind(this);
    // }

    fileUploader_abortUpload(file, uploadInfo) {
        // ...
    }
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

import { DxFileUploaderModule } from 'devextreme-angular';

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        DxFileUploaderModule
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule { }
Vue
App.vue
<template>
    <DxFileUploader ...
        :abort-upload="fileUploader_abortUpload"
    />
</template>

<script>
import 'devextreme/dist/css/dx.light.css';

import DxFileUploader from 'devextreme-vue/file-uploader';

export default {
    components: {
        DxFileUploader
    },
    methods: {
        fileUploader_abortUpload(file, uploadInfo) {
            // ...
        }
    }
}
</script>
React
App.js
import React from 'react';

import 'devextreme/dist/css/dx.light.css';

import FileUploader from 'devextreme-react/file-uploader';

class App extends React.Component {
    // Uncomment the following lines if the function should be executed in the component's context
    // constructor(props) {
    //     super(props);
    //     this.fileUploader_abortUpload = this.fileUploader_abortUpload.bind(this);
    // }

    fileUploader_abortUpload(file, uploadInfo) {
        // ...
    }

    render() {
        return (
            <FileUploader ...
                abortUpload={this.fileUploader_abortUpload}
            />
        );
    }
}
export default App;
ASP.NET Core Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    @* ... *@
    .AbortUpload("abortUpload")
)

<script type="text/javascript">
    function abortUpload(file, uploadInfo) {
        // ...
    }
</script>
ASP.NET MVC Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    @* ... *@
    .AbortUpload("abortUpload")
)

<script type="text/javascript">
    function abortUpload(file, uploadInfo) {
        // ...
    }
</script>

accept

Specifies a file type or several types accepted by the UI component.

Type:

String

Default Value: ''

The value of this property is passed to the accept attribute of the underlying input element. Thus, the property accepts a MIME type or several types separated by a comma. Refer to the input element documentation for information on available values.

Note that the allowedFileExtensions property disables the uploading of the prohibited file types, but does not restrict these file types in the Open File dialog. To filter file types in the Open File dialog, use the accept option.

View Demo

accessKey

Specifies the shortcut key that sets focus on the UI component.

Type:

String

Default Value: undefined

The value of this property will be passed to the accesskey attribute of the HTML element that underlies the UI component.

activeStateEnabled

Specifies whether the UI component changes its visual state as a result of user interaction.

Type:

Boolean

Default Value: false

The UI component switches to the active state when users press down the primary mouse button. When this property is set to true, the CSS rules for the active state apply. You can change these rules to customize the component.

Use this property when you display the component on a platform whose guidelines include the active state change for UI components.

allowCanceling

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

Type:

Boolean

Default Value: true

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

NOTE
This property 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: []

View Demo

Note that the allowedFileExtensions property disables the uploading of the prohibited file types, but does not restrict these file types in the Open File dialog. To filter file types in the Open File dialog, use the accept option.

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

View Demo

Set this property to a positive value to enable chunk upload. The UI component 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

dialogTrigger

Specifies the HTML element which invokes the file upload dialog.

Default Value: undefined

View Demo

This property accepts one of the following values:

  • A CSS selector, or a jQuery selector if you use jQuery

    jQuery
    index.js
    $(function(){
        $("#fileUploaderContainer").dxFileUploader({
            // ...
            dialogTrigger: '.open-button'
        });
    });
    Angular
    app.component.html
    <dx-file-uploader ... 
        dialogTrigger=".open-button"
    >
    </dx-file-uploader>
    Vue
    App.vue
    <template>
        <DxFileUploader ... 
            dialog-trigger=".open-button"
        >
        </DxFileUploader>
    </template>
    <script>
    import { DxFileUploader } from 'devextreme-vue/file-uploader';
    
    export default {
        components: {
            DxFileUploader
        }
    };
    </script>
    React
    App.js
    import FileUploader from 'devextreme-react/file-uploader';
    // ...
    function App() {
        return (
            <FileUploader ... 
                dialogTrigger=".open-button"
            >
            </FileUploader>
        );
    }
  • A jQuery wrapper

    jQuery
    index.js
    $(function(){
        $("#fileUploaderContainer").dxFileUploader({
            // ...
            dialogTrigger: $('.open-button')
        });
    });
  • A DOM element

    jQuery
    index.js
    $(function(){
        $("#fileUploaderContainer").dxFileUploader({
            // ...
            dialogTrigger: document.querySelector('.open-button')
        });
    });
    Angular
    app.component.html
    app.component.ts
    <dx-file-uploader ... 
        [dialogTrigger]="targetElement"
    >
    </dx-file-uploader>
    // ...
    export class AppComponent {
        targetElement: Element;
        constructor() {
            this.targetElement = document.querySelector('.open-button') as Element;
        }
    }
    Vue
    App.vue
    <template>
        <DxFileUploader ... 
            :dialog-trigger="targetElement"
        >
        </DxFileUploader>
    </template>
    <script>
    import { DxFileUploader } from 'devextreme-vue/file-uploader';
    
    export default {
        components: {
            DxFileUploader
        },
        data() {
            return {
                targetElement: null
            }
        },
        mounted() {
            this.targetElement = document.querySelector('.open-button');
        }
    };
    </script>
    React
    App.js
    import React, { useEffect, useState } from 'react';
    import FileUploader from 'devextreme-react/file-uploader';
    // ...
    function App() {
        const [targetElement, setTargetElement] = useState(null);
        useEffect(() => {
            setTargetElement(document.querySelector('.open-button'));
        }, []);
        return (
            <FileUploader ... 
                dialogTrigger={targetElement}
            >
            </FileUploader>
        );
    }

disabled

Specifies whether the UI component responds to user interaction.

Type:

Boolean

Default Value: false

dropZone

Specifies the HTML element in which users can drag and drop files for upload.

Default Value: undefined

View Demo

This property accepts one of the following values:

  • A CSS selector, or a jQuery selector if you use jQuery

    jQuery
    index.js
    $(function(){
        $("#fileUploaderContainer").dxFileUploader({
            // ...
            dropZone: '.test-div'
        });
    });
    Angular
    app.component.html
    <dx-file-uploader ... 
        dropZone=".test-div"
    >
    </dx-file-uploader>
    Vue
    App.vue
    <template>
        <DxFileUploader ... 
            drop-zone=".test-div"
        >
        </DxFileUploader>
    </template>
    <script>
    import { DxFileUploader } from 'devextreme-vue/file-uploader';
    
    export default {
        components: {
            DxFileUploader
        }
    };
    </script>
    React
    App.js
    import FileUploader from 'devextreme-react/file-uploader';
    // ...
    function App() {
        return (
            <FileUploader ... 
                dropZone=".test-div"
            >
            </FileUploader>
        );
    }
  • A jQuery wrapper

    jQuery
    index.js
    $(function(){
        $("#fileUploaderContainer").dxFileUploader({
            // ...
            dropZone: $('.test-div')
        });
    });
  • A DOM element

    jQuery
    index.js
    $(function(){
        $("#fileUploaderContainer").dxFileUploader({
            // ...
            dropZone: document.querySelector('.test-div')
        });
    });
    Angular
    app.component.html
    app.component.ts
    <dx-file-uploader ... 
        [dropZone]="targetElement"
    >
    </dx-file-uploader>
    // ...
    export class AppComponent {
        targetElement: Element;
        constructor() {
            this.targetElement = document.querySelector('.test-div') as Element;
        }
    }
    Vue
    App.vue
    <template>
        <DxFileUploader ... 
            :drop-zone="targetElement"
        >
        </DxFileUploader>
    </template>
    <script>
    import { DxFileUploader } from 'devextreme-vue/file-uploader';
    
    export default {
        components: {
            DxFileUploader
        },
        data() {
            return {
                targetElement: null
            }
        },
        mounted() {
            this.targetElement = document.querySelector('.test-div');
        }
    };
    </script>
    React
    App.js
    import React, { useEffect, useState } from 'react';
    import FileUploader from 'devextreme-react/file-uploader';
    // ...
    function App() {
        const [targetElement, setTargetElement] = useState(null);
        useEffect(() => {
            setTargetElement(document.querySelector('.test-div'));
        }, []);
        return (
            <FileUploader ... 
                dropZone={targetElement}
            >
            </FileUploader>
        );
    }
NOTE
A custom drop zone (dropZone property) is not supported in useForm upload modes.
See Also

elementAttr

Specifies the global attributes to be attached to the UI component's container element.

Selector: dxo-element-attr
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 UI component can be focused using keyboard navigation.

Type:

Boolean

Default Value: true (desktop)

height

Specifies the UI component's height.

Type:

Number

|

String

|

Function

Return Value:

Number

|

String

The UI component's height.

Default Value: undefined

This property accepts a value of one of the following types:

  • Number
    The height in pixels.

  • String
    A CSS-accepted measurement of height. For example, "55px", "20vh", "80%", "inherit".

  • Function (deprecated since v21.2)
    Refer to the W0017 warning description for information on how you can migrate to viewport units.

hint

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

Type:

String

Default Value: undefined

hoverStateEnabled

Specifies whether the FileUploader component changes the state of all its buttons when users hover over them.

Type:

Boolean

Default Value: true

inputAttr

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

Type: any
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
    ],
    // ...
})
Vue
App.vue
<template>
    <DxFileUploader
        :input-attr="inputAttr"
    />
</template>

<script>
import 'devextreme/dist/css/dx.light.css';

import DxFileUploader from 'devextreme-vue/file-uploader';

export default {
    components: {
        DxFileUploader
    },
    data() {
        return {
            inputAttr: { id: 'inputId' }
        }
    }
}
</script>
React
App.js
import 'devextreme/dist/css/dx.light.css';

import FileUploader from 'devextreme-react/file-uploader';

const inputAttr = { id: 'inputId' };

export default function App() {
    return (
        <FileUploader
            inputAttr={inputAttr}
        />
    );
}
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 properties: 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', '' (InternetExplorer, desktop)

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 UI component 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 property's value should end with square brackets if the uploadMode is "useForm". Refer to the Upload Mode topic for an example.
See Also

onBeforeSend

A function that allows you to customize the request before it is sent to the server.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FileUploader

The UI component's instance.

element

HTMLElement | jQuery

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

file

File

An uploaded file.

model any

Model data. Available only if Knockout is used.

request

XMLHttpRequest Object

An XMLHttpRequest for the file.

uploadInfo

UploadInfo

An object that provides information about the file upload session.

Default Value: null

jQuery
JavaScript
$(function() {
    $("#fileUploaderContainer").dxFileUploader({
        // ...
        onBeforeSend: function(e) {
            e.request.withCredentials = true;
        }
    });
});
Angular
app.component.html
app.component.ts
app.module.ts
<dx-file-uploader 
    (onBeforeSend)="onBeforeSend($event)">
    <!-- ... -->
</dx-file-uploader>
import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})

export class AppComponent {
    onBeforeSend(e){
        e.request.withCredentials = true;
    }
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { DxFileUploaderModule } from 'devextreme-angular';

@NgModule({
    imports: [
        DxFileUploaderModule
    ],        
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }
Vue
App.vue
<template>
    <DxFileUploader 
        :on-before-send="onBeforeSend" >            
    </DxFileUploader>
</template>

<script>
    import 'devextreme/dist/css/dx.light.css';

    import { 
        DxFileUploader
        // ... 
    } from 'devextreme-vue/file-uploader';

    export default {
        components: { 
            DxFileUploader
            // ... 
        },
        methods: {
            onBeforeSend(e) {
                e.request.withCredentials = true;
            }
        },         
        data() {
            return {
                //...
            };
        } 
    };
</script>
React
App.js
import React from 'react';
import FileUploader from 'devextreme-react/file-uploader';

const App = () => {
    const onBeforeSend = (e) => {
        e.request.withCredentials = true;
    };

    return (
        <FileUploader onBeforeSend={onBeforeSend}>
            <!-- ... -->               
        </FileUploader>
    );
};

export default App;
ASP.NET MVC Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    .OnBeforeSend("onBeforeSend");
    // ...
)

<script>
    function onBeforeSend(e) {
        e.request.withCredentials = true;
    }
</script>
ASP.NET Core Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    .OnBeforeSend("onBeforeSend");
    // ...
)

<script>
    function onBeforeSend(e) {
        e.request.withCredentials = true;
    }
</script>

onContentReady

A function that is executed when the UI component is rendered and each time the component is repainted.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FileUploader

The UI component's instance.

element

HTMLElement | jQuery

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

model any

Model data. Available only when using Knockout.

Default Value: null

onDisposing

A function that is executed before the UI component is disposed of.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FileUploader

The UI component's instance.

element

HTMLElement | jQuery

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

model any

Model data. Available only if you use Knockout.

Default Value: null

onDropZoneEnter

A function that is executed when the mouse enters a drop zone while dragging a file.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FileUploader

The UI component's instance.

dropZoneElement

HTMLElement | jQuery

A drop zone element.

element

HTMLElement | jQuery

The UI component'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 an EventObject or a jQuery.Event when you use jQuery.

model any

Model data. Available only if Knockout is used.

Default Value: null

View Demo

See Also

onDropZoneLeave

A function that is executed when the mouse leaves a drop zone as it drags a file.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FileUploader

The UI component's instance.

dropZoneElement

HTMLElement | jQuery

A drop zone element.

element

HTMLElement | jQuery

The UI component'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 an EventObject or a jQuery.Event when you use jQuery.

model any

Model data. Available only if Knockout is used.

Default Value: null

View Demo

See Also

onFilesUploaded

A function that is executed when the file upload process is complete.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FileUploader

The UI component's instance.

element

HTMLElement | jQuery

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

model any

Model data. Available only if Knockout is used.

Default Value: null

jQuery
JavaScript
$(function() {
    $("#fileUploaderContainer").dxFileUploader({
        // ...
        onFilesUploaded: function(e) {
            // Your code goes here
        }
    });
});
Angular
app.component.html
app.component.ts
app.module.ts
<dx-file-uploader 
    (onFilesUploaded)="onFilesUploaded($event)">
    <!-- ... -->
</dx-file-uploader>
import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})

export class AppComponent {
    onFilesUploaded(e){
        // ...
    }
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { DxFileUploaderModule } from 'devextreme-angular';

@NgModule({
    imports: [
        DxFileUploaderModule
    ],        
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }
Vue
App.vue
<template>
    <DxFileUploader 
        :on-files-uploaded="onFilesUploaded" >            
    </DxFileUploader>
</template>

<script>
    import 'devextreme/dist/css/dx.light.css';

    import { 
        DxFileUploader
        // ... 
    } from 'devextreme-vue/file-uploader';

    export default {
        components: { 
            DxFileUploader
            // ... 
        },
        methods: {
            onFilesUploaded(e) {
                // ...
            }
        },         
        data() {
            return {
                //...
            };
        } 
    };
</script>
React
App.js
import React from 'react';
import FileUploader from 'devextreme-react/file-uploader';

const App = () => {
    const onFilesUploaded = (e) => {
        // ...
    };

    return (
        <FileUploader onFilesUploaded={onFilesUploaded}>
            <!-- ... -->               
        </FileUploader>
    );
};

export default App;
ASP.NET MVC Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    .OnFilesUploaded("onFilesUploaded");
    // ...
)

<script>
    function onFilesUploaded(e) {
        // ...
    }
</script>
ASP.NET Core Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    .OnFilesUploaded("onFilesUploaded");
    // ...
)

<script>
    function onFilesUploaded(e) {
        // ...
    }
</script>

onInitialized

A function used in JavaScript frameworks to save the UI component instance.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
component

FileUploader

The UI component's instance.

element

HTMLElement | jQuery

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

Default Value: null

onOptionChanged

A function that is executed after a UI component property is changed.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
Name Type Description
model any

Model data. Available only if you use Knockout.

fullName

String

The path to the modified property that includes all parent properties.

element

HTMLElement | jQuery

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

component

FileUploader

The UI component's instance.

name

String

The modified property if it belongs to the first level. Otherwise, the first-level property it is nested into.

value any

The modified property's new value.

previousValue any

The UI component's previous value.

Default Value: null

The following example shows how to subscribe to component property changes:

jQuery
index.js
$(function() {
    $("#fileUploaderContainer").dxFileUploader({
        // ...
        onOptionChanged: function(e) {
            if(e.name === "changedProperty") {
                // handle the property change here
            }
        }
    });
});
Angular
app.component.html
app.component.ts
app.module.ts
<dx-file-uploader ...
    (onOptionChanged)="handlePropertyChange($event)"> 
</dx-file-uploader>
import { Component } from '@angular/core'; 

@Component({ 
    selector: 'app-root', 
    templateUrl: './app.component.html', 
    styleUrls: ['./app.component.css'] 
}) 

export class AppComponent { 
    // ...
    handlePropertyChange(e) {
        if(e.name === "changedProperty") { 
            // handle the property change here
        }
    }
}
import { BrowserModule } from '@angular/platform-browser'; 
import { NgModule } from '@angular/core'; 
import { AppComponent } from './app.component'; 
import { DxFileUploaderModule } from 'devextreme-angular'; 

@NgModule({ 
    declarations: [ 
        AppComponent 
    ], 
    imports: [ 
        BrowserModule, 
        DxFileUploaderModule 
    ], 
    providers: [ ], 
    bootstrap: [AppComponent] 
}) 

export class AppModule { }  
Vue
App.vue
<template> 
    <DxFileUploader ...
        @option-changed="handlePropertyChange"
    />            
</template> 

<script>  
import 'devextreme/dist/css/dx.light.css'; 
import DxFileUploader from 'devextreme-vue/file-uploader'; 

export default { 
    components: { 
        DxFileUploader
    }, 
    // ...
    methods: { 
        handlePropertyChange: function(e) {
            if(e.name === "changedProperty") {
                // handle the property change here
            }
        }
    } 
} 
</script> 
React
App.js
import React from 'react';  
import 'devextreme/dist/css/dx.light.css'; 

import FileUploader from 'devextreme-react/file-uploader'; 

const handlePropertyChange = (e) => {
    if(e.name === "changedProperty") {
        // handle the property change here
    }
}

export default function App() { 
    return ( 
        <FileUploader ...
            onOptionChanged={handlePropertyChange}
        />        
    ); 
} 

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 UI component's instance.

element

HTMLElement | jQuery

The UI component'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 an EventObject or a jQuery.Event when you use jQuery.

file

File

An uploaded file.

model any

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

Note that the onProgress function is not in effect if you use FileUploader in useForm upload mode or call the form.submit method.

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 UI component's instance.

element

HTMLElement | jQuery

The UI component'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 an EventObject or a jQuery.Event when you use jQuery.

file

File

The uploaded file.

message

String

The message displayed by the UI component when the file upload is cancelled.

model any

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 UI component's instance.

element

HTMLElement | jQuery

The UI component'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 an EventObject or a jQuery.Event when you use jQuery.

file

File

The uploaded file.

message

String

The message displayed by the UI component when uploading is finished.

model any

Model data. Available only if Knockout is used.

request

XMLHttpRequest Object

Specifies an XMLHttpRequest for the file.

Default Value: null

Note that the onUploaded function is not in effect if you use FileUploader in useForm upload mode or call the form.submit method.

See Also

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 UI component's instance.

element

HTMLElement | jQuery

The UI component'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 an EventObject or a jQuery.Event when you use jQuery.

file

File

The uploaded file.

message

String

The message displayed by the UI component on uploading failure.

model any

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
app.component.html
app.component.ts
app.module.ts
<dx-file-uploader 
    (onUploadError)="onUploadError($event)">
    <!-- ... -->
</dx-file-uploader>
import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})

export class AppComponent {
    onUploadError(e){
        var xhttp = e.request;
        if (xhttp.readyState == 4 && xhttp.status == 0) {
            console.log("Connection refused.");
        } 
    }
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { DxFileUploaderModule } from 'devextreme-angular';

@NgModule({
    imports: [
        DxFileUploaderModule
    ],        
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }
Vue
App.vue
<template>
    <DxFileUploader 
        :on-upload-error="onUploadError" >            
    </DxFileUploader>
</template>

<script>
    import 'devextreme/dist/css/dx.light.css';

    import { 
        DxFileUploader
        // ... 
    } from 'devextreme-vue/file-uploader';

    export default {
        components: { 
            DxFileUploader
            // ... 
        },
        methods: {
            onUploadError(e) {
                var xhttp = e.request;
                if (xhttp.readyState == 4 && xhttp.status == 0) {
                    console.log("Connection refused.");
                } 
            }
        },         
        data() {
            return {
                //...
            };
        } 
    };
</script>
React
App.js
import React from 'react';
import FileUploader from 'devextreme-react/file-uploader';

const App = () => {
    const onUploadError = (e) => {
        var xhttp = e.request;
        if (xhttp.readyState == 4 && xhttp.status == 0) {
            console.log("Connection refused.");
        } 
    };

    return (
        <FileUploader onUploadError={onUploadError}>
            <!-- ... -->               
        </FileUploader>
    );
};

export default App;
ASP.NET MVC Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    .OnUploadError("onUploadError");
    // ...
)

<script>
    function onUploadError(e) {
        var xhttp = e.request;
        if (xhttp.readyState == 4 && xhttp.status == 0) {
            console.log("Connection refused.");
        } 
    }
</script>
ASP.NET Core Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    .OnUploadError("onUploadError");
    // ...
)

<script>
    function onUploadError(e) {
        var xhttp = e.request;
        if (xhttp.readyState == 4 && xhttp.status == 0) {
            console.log("Connection refused.");
        } 
    }
</script>
See Also

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 UI component's instance.

element

HTMLElement | jQuery

The UI component'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 an EventObject or a jQuery.Event when you use jQuery.

file

File

The uploaded file.

model any

Model data. Available only if Knockout is used.

request

XMLHttpRequest Object

Specifies an XMLHttpRequest for the file.

Default Value: null

Note that the onUploadStarted function is not in effect if you use FileUploader in useForm upload mode or call the form.submit method.

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 any

Model data. Available only if Knockout is used.

event

Event (jQuery or EventObject)

The event that caused the function to execute. It is an EventObject or a jQuery.Event when you use jQuery. This field is undefined if the value is changed programmatically.

element

HTMLElement | jQuery

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

component

FileUploader

The UI component'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

Set the readOnly property to true to enable the following functionality:

  • File upload in UI is disabled. This also includes a HTML element specified in the dialogTrigger property.
  • Built-in action buttons are disabled.

Note that already selected files are available for upload in readOnly mode.

readyToUploadMessage

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

Type:

String

Default Value: 'Ready to upload'

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

rtlEnabled

Switches the UI component to a right-to-left representation.

Type:

Boolean

Default Value: false

When this property is set to true, the UI component 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
});

DataGrid Demo Navigation UI Demo Editors Demo

selectButtonText

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

Type:

String

Default Value: 'Select File'

showFileList

Specifies whether or not the UI component 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 property will be passed to the tabindex attribute of the HTML element that underlies the UI component.

uploadAbortedMessage

The message displayed by the UI component when the file upload is cancelled.

Type:

String

Default Value: 'Upload cancelled'

This property is only available if the uploadMode property is set to "instantly".

uploadButtonText

The text displayed on the button that starts uploading.

Type:

String

Default Value: 'Upload'

The property makes sense only if the uploadMode property 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:

UploadInfo

Information about the file upload session.

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({
        uploadChunk: function(file, uploadInfo) {
            // your code
        }
    });      
});
Angular
app.component.html
app.component.ts
app.module.ts
<dx-file-uploader ...
    [uploadChunk]="fileUploader_uploadChunk">
</dx-file-uploader>
import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent {
    // Uncomment the following lines if the function should be executed in the component's context
    // constructor() {
    //     this.fileUploader_uploadChunk = this.fileUploader_uploadChunk.bind(this);
    // }

    fileUploader_uploadChunk(file, uploadInfo) {
        // ...
    }
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

import { DxFileUploaderModule } from 'devextreme-angular';

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        DxFileUploaderModule
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule { }
Vue
App.vue
<template>
    <DxFileUploader ...
        :upload-chunk="fileUploader_uploadChunk"
    />
</template>

<script>
import 'devextreme/dist/css/dx.light.css';

import DxFileUploader from 'devextreme-vue/file-uploader';

export default {
    components: {
        DxFileUploader
    },
    methods: {
        fileUploader_uploadChunk(file, uploadInfo) {
            // ...
        }
    }
}
</script>
React
App.js
import React from 'react';

import 'devextreme/dist/css/dx.light.css';

import FileUploader from 'devextreme-react/file-uploader';

class App extends React.Component {
    // Uncomment the following lines if the function should be executed in the component's context
    // constructor(props) {
    //     super(props);
    //     this.fileUploader_uploadChunk = this.fileUploader_uploadChunk.bind(this);
    // }

    fileUploader_uploadChunk(file, uploadInfo) {
        // ...
    }

    render() {
        return (
            <FileUploader ...
                uploadChunk={this.fileUploader_uploadChunk}
            />
        );
    }
}
export default App;
ASP.NET Core Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    @* ... *@
    .UploadChunk("uploadChunk")
)

<script type="text/javascript">
    function uploadChunk(file, uploadInfo) {
        // ...
    }
</script>
ASP.NET MVC Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    @* ... *@
    .UploadChunk("uploadChunk")
)

<script type="text/javascript">
    function uploadChunk(file, uploadInfo) {
        // ...
    }
</script>

uploadCustomData

Specifies custom data for the upload request.

Type: any
Default Value: {}

jQuery
JavaScript
$(function() {
    $("#fileUploaderContainer").dxFileUploader({
        // ...
        uploadCustomData: {
            __RequestVerificationToken: document.getElementsByName("__RequestVerificationToken")[0].value
        }
    });
});
Angular
app.component.html
app.module.ts
<dx-file-uploader id="fileUploader">
    [uploadCustomData]="{
        __RequestVerificationToken: document.getElementsByName("__RequestVerificationToken")[0].value
    }"
    <!-- ... -->
</dx-file-uploader>
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { DxFileUploaderModule } from 'devextreme-angular';

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        DxFileUploaderModule
    ],
    //...
})
export class AppModule { }    
Vue
App.vue
<template>
    <DxFileUploader
        :upload-custom-data="uploaderCustomData" >   
    </DxFileUploader>
</template>
<script>
    import 'devextreme/dist/css/dx.light.css';    

    import {
        DxFileUploader
    } from 'devextreme-vue/file-uploader';

    export default {
        components: {
            DxFileUploader
        },
        data() {
            return {
                uploaderCustomData: {
                    __RequestVerificationToken: document.getElementsByName("__RequestVerificationToken")[0].value
                }
            };
        }            
    };
</script>
React
App.js
import React from 'react';

import 'devextreme/dist/css/dx.light.css';

import FileUploader from 'devextreme-react/file-uploader';

const uploaderCustomData = {
    __RequestVerificationToken: document.getElementsByName("__RequestVerificationToken")[0].value
};

class App extends React.Component {
    render() {
        return (
            <FileUploader uploadCustomData={uploaderCustomData} >
            </FileUploader>
        );
    }
}
export default App;
ASP.NET MVC Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    .UploadCustomData(new[] { __RequestVerificationToken: document.getElementsByName("__RequestVerificationToken")[0].value })
    // ...
)
ASP.NET Core Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    .UploadCustomData(new[] { __RequestVerificationToken: document.getElementsByName("__RequestVerificationToken")[0].value })
    // ...
)

uploadedMessage

The message displayed by the UI component when uploading is finished.

Type:

String

Default Value: 'Uploaded'

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

uploadFailedMessage

The message displayed by the UI component on uploading failure.

Type:

String

Default Value: 'Upload failed'

The property makes sense only if the uploadMode property 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 UI component 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);
            // ...
        }
    });         
});
Angular
app.component.html
app.component.ts
app.module.ts
<dx-file-uploader ...
    [uploadFile]="fileUploader_uploadFile">
</dx-file-uploader>
import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent {
    // Uncomment the following lines if the function should be executed in the component's context
    // constructor() {
    //     this.fileUploader_uploadFile = this.fileUploader_uploadFile.bind(this);
    // }

    fileUploader_uploadFile(file, progressCallback) {
        // your code
        progressCallback(100);
        // ...
        progressCallback(200);
        // ...
    }
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

import { DxFileUploaderModule } from 'devextreme-angular';

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        DxFileUploaderModule
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule { }
Vue
App.vue
<template>
    <DxFileUploader ...
        :upload-file="fileUploader_uploadFile"
    />
</template>

<script>
import 'devextreme/dist/css/dx.light.css';

import DxFileUploader from 'devextreme-vue/file-uploader';

export default {
    components: {
        DxFileUploader
    },
    methods: {
        fileUploader_uploadFile(file, progressCallback) {
            // your code
            progressCallback(100);
            // ...
            progressCallback(200);
            // ...
        }
    }
}
</script>
React
App.js
import React from 'react';

import 'devextreme/dist/css/dx.light.css';

import FileUploader from 'devextreme-react/file-uploader';

class App extends React.Component {
    // Uncomment the following lines if the function should be executed in the component's context
    // constructor(props) {
    //     super(props);
    //     this.fileUploader_uploadFile = this.fileUploader_uploadFile.bind(this);
    // }

    fileUploader_uploadFile(file, progressCallback) {
        // your code
        progressCallback(100);
        // ...
        progressCallback(200);
        // ...
    }

    render() {
        return (
            <FileUploader ...
                uploadFile={this.fileUploader_uploadFile}
            />
        );
    }
}
export default App;
ASP.NET Core Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    @* ... *@
    .UploadFile("uploadFile")
)

<script type="text/javascript">
    function uploadFile(file, progressCallback) {
        // your code
        progressCallback(100);
        // ...
        progressCallback(200);
        // ...
    }
</script>
ASP.NET MVC Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    @* ... *@
    .UploadFile("uploadFile")
)

<script type="text/javascript">
    function uploadFile(file, progressCallback) {
        // your code
        progressCallback(100);
        // ...
        progressCallback(200);
        // ...
    }
</script>

uploadHeaders

Specifies headers for the upload request.

Type: any
Default Value: {}

uploadMethod

Specifies the method for the upload request.

Type:

String

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

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

uploadMode

Specifies how the UI component uploads files.

Type:

String

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

View Demo

Depending on the uploadMode, the FileUploader UI component uses an HTML form or a FormData interface with a series of Ajax requests to upload files. The uploadMode property 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.

See Also

uploadUrl

Specifies a target Url for the upload request.

Type:

String

Default Value: '/'

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

View Demo

validationError

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

Type: any
Default Value: null

See Also

validationErrors

An array of the validation rules that failed.

Type:

Array<any>

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

When you assign "invalid" to validationStatus, you can also use the validationErrors array to set an error message as shown below:

jQuery
index.js
$(function() {
    const fileUploader = $("#fileUploaderContainer").dxFileUploader({
        // ...
    }).dxFileUploader("instance");

    function setInvalidStatus(message) {
        fileUploader.option({
            validationStatus: "invalid",
            validationErrors: [{ message: message }]
        });
    }
});
Angular
app.component.html
app.component.ts
<dx-file-uploader
    [validationStatus]="validationStatus"
    [validationErrors]="validationErrors">
</dx-file-uploader>
// ...
export class AppComponent {
    validationStatus: string = "valid";
    validationErrors: any;
    // ...
    setInvalidStatus(message) {
        this.validationStatus = "invalid";
        this.validationErrors = [{ message: message }];
    }
}
Vue
App.vue
<template>
    <DxFileUploader ...
        :validation-status="validationStatus"
        :validation-errors="validationErrors"
    />
</template>

<script>
    // ...
    export default {
        // ...
        data() {
            return {
                validationStatus: "valid",
                validationErrors: []
            }
        },
        methods: {
            setInvalidStatus(message) {
                this.validationStatus = "invalid";
                this.validationErrors = [{ message: message }];
            }
        }
    }
</script>
React
App.js
import React, { useState } from 'react';
// ...

function App() {
    const [validationStatus, setValidationStatus] = useState("valid");
    const [validationErrors, setValidationErrors] = useState([]);

    const setInvalidStatus = message => {
        setValidationStatus("invalid");
        setValidationErrors([{ message: message }]);
    }

    return (
        <FileUploader
            validationStatus={validationStatus}
            validationErrors={validationErrors}
        />
    ); 

};
export default App;

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 UI component is visible.

Type:

Boolean

Default Value: true

width

Specifies the UI component's width.

Type:

Number

|

String

|

Function

Return Value:

Number

|

String

The UI component's width.

Default Value: undefined

This property accepts a value of one of the following types:

  • Number
    The width in pixels.

  • String
    A CSS-accepted measurement of width. For example, "55px", "20vw", "80%", "auto", "inherit".

  • Function (deprecated since v21.2)
    Refer to the W0017 warning description for information on how you can migrate to viewport units.