ng-file-select does not work when request fails

jbmyid picture jbmyid · Oct 21, 2014 · Viewed 7.5k times · Source

I am using angular-file-upload in my angular project. https://github.com/danialfarid/angular-file-upload

<span ng-file-select="onFileSelect($files)" class="btn btn-primary btn-lg" role="button">Upload employee list</span>

Its working fine for first uplaod but when the upload fails, afterwards it does not work.

Please suggest any workaround.

Thanks in advance.

Answer

jbmyid picture jbmyid · Dec 11, 2014

I got this fix. Its not actually after just error or failure. The upload calls on change event. So when success or error you have to reset the field.

I called this after success/failure. now it works fine.

$("input#fileSelect").val("");

and the span is like

<span ng-file-select="onFileSelect($files)" class="btn btn-primary btn-lg" role="button" id="fileSelect">Upload employee list</span>