1

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
   }
});

1 Answer 1

1

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
   }
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.