I'm following this advice to clear a FILE input in IE (specifically using the clone method, also described here, though I've also tried replacing with literal HTML). My goal was to have a "remove file" button in a custom styled upload control that would clear the input and "reset" it in such a way that it would be ready to receive another file.
The problem is (and in IE only, tested up to IE9), while I can clear the FILE input using this method, I can't use a change event on the replaced FILE input. I suspect it is because the clone has the same ID as the original and both exist then in the DOM, but this is only a theory... Can this be worked around?
To hopefully illustrate/clarify the issue: this FIDDLE:
In all non-IE browsers,
- Click "Add File" and select a file
- value is filled in to the file field (which would normally be hidden from view)
- "None Selected" is changed to "File Selected"
- Click "Remove File" on the same line - everything is reset and ready to go again.
- Click "Add File" and the process repeats normally
In IE,
- 1-4 above the same
- Click "Add File" again and the new file can be selected, but the subsequent actions (3-4) don't occur again
Is there a solution to this that works in "all" browsers?