I'm working with a simple html type="file" input, and I'm having an issue in Chrome. Specifically, when you browse to and choose a file, it saves the value. However, if you re-browse, then press cancel it will clear out the value.
The html is simple:
<input type="file">
Here is a simple fiddle- http://jsfiddle.net/78ghn/.
This doesn't happen in other browsers -- is there a way to force Chrome to retain the value??
I was unable to find a native implementation for this, so I tried my own workaround. It takes input from a custom CSS button overlay, then adds the actual
input
element to a list and replaces it with an empty one. The value is read and displayed, as it would be with a normalinput
. It is not included, but submitting it would involve moving the originalinput
(last element oful
withid='b'
) to aform
and submitting it via JavaScript. It is not optimal, but it does work.