Reputation: 131
I am using angular-file-upload. i have added a filter to limit the file upload size. But i cannot find how to catch it so i could display a message to the user.
self.uploader.filters.push({
'name': 'enforceMaxFileSize',
'fn': function(item) {
return item.size <= 10485760; // 10 MiB to bytes
}
});
Upvotes: 1
Views: 247
Reputation: 2566
Try this
self.uploader.filters.push({
'name': 'enforceMaxFileSize',
'fn': function(item) {
if(item.size > 10485760){
alert('Max file size is 10485760');
}
return item.size <= 10485760; // 10 MiB to bytes
}
});
Upvotes: 1