user3428228
user3428228

Reputation: 131

Angular-JS File Upload using angular-file-upload - Limiting File Size display message

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

Answers (1)

Haris Bouchlis
Haris Bouchlis

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

Related Questions