Search code examples
angularjsangular-file-upload

ng-file-select does not work when request fails


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.


Solution

  • 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>