Angular 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.component.html
app.component.ts
- <dx-file-uploader
- [allowedFileExtensions]="allowedFileExtensions"
- [minFileSize]="1024"
- [maxFileSize]="1024 * 1024"
- ></dx-file-uploader>
- import { DxFileUploaderModule } from "devextreme-angular";
- @Component({
- imports: [DxFileUploaderModule],
- })
- export class AppComponent {
- allowedFileExtensions = ['.jpeg', '.png'];
- }
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: