There's kinda a law against taking any kind of control over a file input. You could replace the file element with another:
Code:
var nfile = document.createElement('input');
nfile.type = 'file';
nfile.id = 'image_file';
nfile.name = 'image_file';
nfile.size = '35';
nfile.accept = 'image/jpeg';
nfile.onchange = function(){showDiv('submitDiv');return true;};
nfile.onkeypress = function(){return nokeys(event)};
document.getElementById('image_file').parentNode.replaceChild(nfile, document.getElementById('image_file'));
Do that instead of:
Code:
document.getElementById('image_file').value = "";
But if your file input is in a form - say:
HTML Code:
<form name="file_form" action="#">
<input name="image_file" id="image_file"" type="file" size="60" value="" />
<input type="hidden" name="setTime" value="<?php echo $current; ?>" />
<input type="hidden" name="pchange" value="Change File" />
<input type="submit" value="Change File" /> <b>( Changes Image )</b>
</form>
You can simply reset the form:
Code:
document.forms.file_form.reset();
I just tested that in IE 9 and it works. And it won't affect the hidden fields because a reset will reset them to the value thay had when the page first loaded.
But that cuts both ways. If the file input had an initial value, a reset will restore that rather than simply emptying its value.
Bookmarks