1. 程式人生 > >input file選擇檔案上傳後清空選擇框檔案資訊兩種解決方案

input file選擇檔案上傳後清空選擇框檔案資訊兩種解決方案

上傳檔案時,選擇了檔案後想清空檔案路徑。用兩種方法解決 

<input type="file" id="fileupload" name="file" /> 
第一種:
var obj = document.getElementById('fileupload') ; 
obj.select(); 
document.selection.clear(); 
第二種: 
var obj = document.getElementById('fileupload') ; 
obj.outerHTML=obj.outerHTML; 

我傾向於第二種。