清空input type=file的value值的方法
在ajax的开发中,需要处理对文件上传的控件的值的清理,默认情况下,浏览器的安全性不让操作input type=file的value项,解决方法如下:
![](https://www.cnblogs.com/Emoticons/qface/055611161.gif)
对于input type='file'的值的清理方法如下:
function refreshUploader(who){
// pass who as argument,
// or who=document.getElementsByName('xx_file')[0];
var who2= who.cloneNode(false);
who2.onchange= who.onchange;// events are not cloned
who.parentNode.replaceChild(who2,who);
}
![](https://www.cnblogs.com/Emoticons/qface/055611161.gif)
对于input type='file'的值的清理方法如下:
function refreshUploader(who){
// pass who as argument,
// or who=document.getElementsByName('xx_file')[0];
var who2= who.cloneNode(false);
who2.onchange= who.onchange;// events are not cloned
who.parentNode.replaceChild(who2,who);
}