使用jQuery從文件輸入獲得完整路徑當我打電話的時候val()的輸入type="file"我只得到文件名,而不是完整路徑。我怎么才能走滿路呢?
2 回答

動漫人物
TA貢獻1815條經驗 獲得超10個贊
當使用輸入類型=file對象選擇文件時,Value屬性的值取決于用于顯示包含輸入對象的Web頁面的安全區域的“當將文件上載到服務器時包含本地目錄路徑”安全設置的值。
只有在啟用此設置時才返回所選文件的完全限定文件名。禁用此設置時,InternetExplorer 8將本地驅動器和目錄路徑替換為字符串C:\fakepath\,以防止不適當的信息泄露。

森林海
TA貢獻2011條經驗 獲得超2個贊
<input type="file" id="i_file" value=""> <input type="button" id="i_submit" value="Submit"> <br><img src="" width="200" style="display:none;" /> <br><div id="disp_tmp_path"></div>
$('#i_file').change( function(event) {var tmppath = URL.createObjectURL(event.target.files[0]); $("img").fadeIn("fast").attr('src',URL.createObjectURL(event.target.files[0])); $("#disp_tmp_path").html("Temporary Path(Copy it and try pasting it in browser address bar) --> <strong>["+tmppath+"]</strong>");});
- 2 回答
- 0 關注
- 621 瀏覽
添加回答
舉報
0/150
提交
取消