Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

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
   }
});
share|improve this question

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
   }
});
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.