It is impossible to clear upload file input box. The only standard thing u can use is a .reset() method of the form but it is not good. It will reset all other fields. File input box is READ ONLY, however there is a trick you can do.

The trick is basically to re-create the field from scratch.

Using a jQuery:

$("#filefield_id").parent().html($("#filefield_id").parent().html());

Standard Javascript:

document.getElementById("filefield_id").innerHTML = document.getElementById("filefield_id").innerHTML;

Dima Svirid

Software architect, JAVA, Spring, Hibernate, AngularJs, Backbone, MongoDB, Oracle. CTO and Co-Founder of Homeadnet.com

More Posts

Follow Me:

Tagged with:
 

One Response to Clear upload file input box

  1. Alex Smirnov says:

    Nice trick

Leave a Reply