Clear HTML File Input

HTML file

– javascript function
function clearFileInput()
{
var oldInput = document.getElementById(“fileInput”);

var newInput = document.createElement(“input”);

newInput.type = “file”;
newInput.id = oldInput.id;
newInput.name = oldInput.name;
newInput.className = oldInput.className;
newInput.style.cssText = oldInput.style.cssText;
// copy any other relevant attributes

oldInput.parentNode.replaceChild(newInput, oldInput);
}

Share