我在HTML中使用屬性type =「file」的輸入標籤。 如果我瀏覽和選擇圖像,並嘗試獲取文件的路徑與$(「file_upload」)VAL()腳本返回路徑「C:\ fakepath \ img_name」。如何在java腳本中獲取文件路徑表單輸入標籤
我需要獲取此路徑並將其設置爲從java腳本輸入標記的默認值。
請幫我這個。
腳本:
$(document).ready(function() {$('#imgUpload_edit').change(
function(){if ($(this).val()) {alert($('#imgUpload_edit').val());} }); });
HTML:
<FORM id="frmImgUpload_edit" ENCTYPE="multipart/form-data" ACTION="" METHOD="POST">
<label for="imgUpload_edit" id="bold-text_edit">Select an image for the Device Type:</label>
<input type="file" id="imgUpload_edit" name="deviceTypeImage_edit" size="10000"/>
<div id="imageEditDeviceType"></div>
</FORM>
可能重複的[如何解決C:\ fakepath?](http://stackoverflow.com/questions/4851595/how-to-resolve-the-c-fakepath) – Quentin