[转]将input file的选择的文件清空

本文转自:http://hi.baidu.com/xiongshihu/item/125c79b47632e794194697f5

上传文件时,选择了文件后想清空文件路径的两种办法:

JS代码 <input type="file" id="fileupload" name="file" /> 

第一种: (display:none时不能用)

var obj = document.getElementById('fileupload') ; obj.select();  
document.selection.clear(); 

第二种:(无论display:none或block都可以用)

var obj = document.getElementById('fileupload') ; obj.outerHTML=obj.outerHTML; 

原文地址:https://www.cnblogs.com/freeliver54/p/3209127.html