Search code examples
angularjsng-file-upload

ngf-min-size for ng-file-upload


I have seen in the examples that there is a way to limit the max-size of incoming file uploads.

Is there also a way to limit the min-size?

Additionally, is there a way to display a message to the user if their file doesn't fit the requirements?


Solution

  • You would use :

    ngf-min-size="2MB" // size in bytes. Alternatively you can use 10KB or 10MB as we did here
    

    You could then do something like this to check for errors....

    <i ng-show="myForm.file.$error.maxSize">File too large 
          {{myFile.size / 1000000|number:1}}MB: max 2M</i>
    

    You may find the following exampleuseful: http://jsfiddle.net/danialfarid/maqbzv15/38/