All docs
V24.1
24.2
24.1
23.2
23.1
22.2
22.1
21.2
21.1
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2.
19.1
The page you are viewing does not exist in version 19.1.
18.2
The page you are viewing does not exist in version 18.2.
18.1
The page you are viewing does not exist in version 18.1.
17.2
The page you are viewing does not exist in version 17.2.

JavaScript/jQuery FileUploader - File Validation

The FileUploader allows you to restrict the extension (allowedFileExtensions) and size (minFileSize and maxFileSize) of the file being uploaded. Note that the minimum and maximum file sizes should be specified in bytes:

jQuery
JavaScript
$(function() {
    $("#fileUploaderContainer").dxFileUploader({
        // ...
        allowedFileExtensions: [".jpg", ".png"],
        minFileSize: 1024, // 1 KB
        maxFileSize: 1024 * 1024 // 1 MB
    });
});
Angular
HTML
TypeScript
<dx-file-uploader ...
    [allowedFileExtensions]="['.jpg', '.png']"
    [minFileSize]="1024" <!-- 1 KB -->
    [maxFileSize]="1024 * 1024"> <!-- 1 MB -->
</dx-file-uploader>
import { DxFileUploaderModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxFileUploaderModule
    ],
    // ...
})
Vue
App.vue
<template>
    <DxFileUploader
        :allowed-file-extensions="allowedFileExtensions"
        :min-file-size="1024"
        :max-file-size="1024*1024" >   
    </DxFileUploader>
</template>
<script>
    import 'devextreme/dist/css/dx.light.css';    

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

    export default {
        components: {
            DxFileUploader
        },
        data() {
            return {
                allowedFileExtensions: ['.jpeg', '.png']
            };
        }            
    };
</script>
React
App.js
import React from 'react';

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

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

const allowedFileExtensions = ['.jpeg', '.png'];

class App extends React.Component {
    render() {
        return (
            <FileUploader 
                allowedFileExtensions={allowedFileExtensions} 
                maxFileSize={1024*1024}
                minFileSize={1024}
                >
            </FileUploader>
        );
    }
}
export default App;
ASP.NET MVC Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    .AllowedFileExtensions(new[] { ".jpeg", ".png" })
    .MaxFileSize(1024*1024)
    .MinFileSize(1024)
    // ...
)
ASP.NET Core Controls
Razor C#
@(Html.DevExtreme().FileUploader()
    .AllowedFileExtensions(new[] { ".jpeg", ".png" })
    .MaxFileSize(1024*1024)
    .MinFileSize(1024)
    // ...
)

Files are validated on the client. However, you should also implement server-side validation. Refer to the demo below to see an example for an ASP.NET server.

View Demo