How to show the size of a file that failed to upload to ng-file-upload?

The ng-file-upload documentation shows usage patterns . The first script displays a confirmation message for the 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 violin and upload a file larger than 2 Ml, the verification message says:

 File too large MB: max 2M 

Thus, the expression {{picFile.size / 1000000|number:1}} missing from the message. It looks like picFile.size not installed. Is there any way to show the size?

+5
source share
1 answer

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

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

+12
source

Source: https://habr.com/ru/post/1239413/


All Articles