onErrorItem is not invoking #520

Open
opened 2016-12-07 18:10:50 +00:00 by vdevarapalli · 3 comments
vdevarapalli commented 2016-12-07 18:10:50 +00:00 (Migrated from github.com)

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

### 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: 5*1024*1024 // 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
Sampath-Lokuge commented 2017-01-21 14:56:24 +00:00 (Migrated from github.com)

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.

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.
eshinx1 commented 2017-01-24 17:27:24 +00:00 (Migrated from github.com)

@Sampath-Lokuge @vdevarapalli

try this

this worked for both maxFileSize and allowedMimeType.

this.uploader.onWhenAddingFileFailed = (fileItem) => {
console.log("fail", fileItem);
//this.failFlag = true;
}

@Sampath-Lokuge @vdevarapalli try this this worked for both maxFileSize and allowedMimeType. this.uploader.onWhenAddingFileFailed = (fileItem) => { console.log("fail", fileItem); //this.failFlag = true; }
vdevarapalli commented 2017-02-10 21:45:00 +00:00 (Migrated from github.com)

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

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
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#520