How To Clear An HTML File Input Field

Published Date Author: , Posted July 19th, 2012 at 9:59:36am

An HTML file input can’t be cleared by normal means (i.e. setting the value to null or an empty string) because of browser security restrictions. In most browsers, setting a null value attribute either will have no effect or cause an error. Creating a new element that clones the old element and swap the two bypasses this restriction.

A simple example:

No comments as yet.

Leave Your Comment  Leave a comment

All fields marked with "*" are required.