React FileUploader - File Validation
FileUploader allows you to restrict uploaded file sizes and extensions using the following properties:
Define minimum and maximum file sizes in bytes. The following code snippet specifies 1 KB minimum and 1 MB maximum sizes:
App.tsx
- import { FileUploader } from 'devextreme-react/file-uploader';
- const allowedFileExtensions = ['.jpeg', '.png'];
- function App() {
- return (
- <FileUploader
- allowedFileExtensions={allowedFileExtensions}
- minFileSize={1024}
- maxFileSize={1024*1024}
- />
- );
- }
FileUploader validates files on the client. You should also validate uploaded files on the server. Refer to the following demo for an ASP.NET server validation example: