Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am working on a project where I have used the Angular file uploader:

template: '<input type="file" id="files" name="files[]" multiple /><output id="list"></output>',

...and have set a 'change' event listener to this file uploader:

document.getElementById('files').addEventListener('change', handleFileSelect, false);

If my user selects a list of files, my callback is triggered and the list of files can be retrieved. This is not the issue.

I then populate a dialog with the list of files. The user can then choose to either delete one or many of the files before finishing the upload, or can cancel the upload all together.

If the user deletes all of the files or cancels the upload, returns to the upload dialog, and selects the same list of files, the 'change' event listener is not triggered because the value of the input never actually changed.

Is there any way that I can set a 'click' event on the "Open" button of the file uploader(the input box) instead?

share|improve this question

1 Answer 1

Just solved my problem.

In the callback to my 'change' event listener (handleFileSelect), I reset the value of the file uploader to "". Now, each time a file is selected, whether it is the same list or not, the 'change' event is triggered.

document.getElementById('files').value = "";
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.