onErrorItem is not invoking #520
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
onErrorItem is not invoking when i upload invalid file ( invalid ext file)..
i like to show error to user when invalid file is uploaded.
export class UploadComponent implements OnInit {
private zone: NgZone;
private options: Object;
private progress: number = 0;
private response: any = {};
public uploader:FileUploader = new FileUploader({url: 'http://localhost:10051/api/',
autoUpload: true,
allowedMimeType: ['image/png', 'image/jpg', 'image/bmp', 'application/pdf'],
maxFileSize: 510241024 // 5 MB
});
ngOnInit() {
this.zone = new NgZone({ enableLongStackTrace: false });
this.uploader.onCompleteItem = (item:any, response:any, status:any, headers:any) => {
if (status === 200) {
this.hideUploadForm();
}
};
this.uploader.onErrorItem = (item:any, response:any, status:any, headers:any) => {
console.log(response);
};
}
this.uploader.onErrorItem is not invoking when i upload invalid file..
how can i display error message when i upload invalid file
Thanks
Hi @vdevarapalli
Have you found out a method to over come this issue ? In other words to show an error message to the user ? Thanks.
@Sampath-Lokuge @vdevarapalli
try this
this worked for both maxFileSize and allowedMimeType.
this.uploader.onWhenAddingFileFailed = (fileItem) => {
console.log("fail", fileItem);
//this.failFlag = true;
}
onWhenAddingFileFailed is invoking only if it is a single file upload.
if i am trying upload multiple files with more than maxFileSize (5 MB size ) ... onWhenAddingFileFailed is not invoking ..
how can i show error message when uploaded files size is greater than maxFileSize