Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show the file size which failed to upload in ng-file-upload?

The ng-file-upload documentation shows samples of usage. The first sample fiddle displays a validation message for file size:

<input type="file" ngf-select ng-model="picFile" name="file"    
             accept="image/*" ngf-max-size="2MB" required>
      <i ng-show="myForm.file.$error.required">*required</i><br>
      <i ng-show="myForm.file.$error.maxSize">File too large 
          {{picFile.size / 1000000|number:1}}MB: max 2M</i>

However, when I run the fiddle and upload a file larger than 2M, the validation message says:

File too large MB: max 2M

So the expression {{picFile.size / 1000000|number:1}} is absent from the message. It looks like picFile.size is not set. Is there a way to show the size?

like image 673
camcam Avatar asked Dec 29 '15 09:12

camcam


1 Answers

Updated the sample page: http://jsfiddle.net/danialfarid/maqbzv15/544/

You can use ngf-model-invalid="errorFiles" and then get the invalid file size by errorFiles[0].size.

like image 174
danial Avatar answered Nov 14 '22 13:11

danial