Hello,
File Upload element is a protected element in most of the browsers and browser's will not allow Javascript to alter the value of this element[
^].
However you can delete this element on the fly and re-create the same with exact same attributes of the deleted element and append it in the DOM, this way it will clear the value of this element. below code snippet shows how this canbe done.
lt;head>
<script type="text/javascript">
function clearForm(ctrlId) {
var old = document.getElementById(ctrlId);
var newElm = document.createElement('input');
newElm.type = "file";
newElm.id = ctrlId;
newElm.name = old.name;
newElm.className = old.className;
old.parentNode.replaceChild(newElm, old);
}
</script>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
<form id="frmMain">
<div id="fuDiv">
<input type="file" id="fluPhoto"/><br/>
</div>
<a href="#" onclick="clearForm('fluPhoto')">Clear</a>
</form>
</body>
</html>
Regards,