3 Replies Latest reply: Feb 8, 2012 4:29 AM by ra5ul
benedicke Level 1 Level 1

I have a very simple form with input type="file" and a listener of onchange event for this field.


Consider the following situation.


1. User selected file A and press "upload" button. I send the file to the server via AJAX.


2. Now I need to clear the file field. I tried different ways to do this:

- set value of input to null or ""

- call "reset" method of the form

- reset innerHtml/outerHtml

- use input type=reset to reset the form


3. Whatever I do the value of the input seem to be clear, but! If I select the same file A in this input "onchange" event will not be fired. This is not convenient because in our case sometimes user will need to do re-upload of the file with the same name.


In other browsers (like Chrome, Firefox) it is enough to set value of input to null to get onchange event fired when we select the same or another file.

In Safari nothing works and it looks like a browser issue.

MacBook Pro, Mac OS X (10.6.7)
Reply by ra5ul on Feb 7, 2012 4:37 PM Helpful

i'm pretty sure this was fixed along with bug 63929 (https://bugs.webkit.org/show_bug.cgi?id=63929).  onchange fired consistently when i tested a recent webkit nightly build.

Reply by ra5ul on Feb 8, 2012 4:29 AM Helpful

it probably won't be in the next release of safari, but a future one down the line.


chrome is webkit based but uses a different javascript engine (http://code.google.com/p/v8/).

All replies