我在 HTML 中使用属性 type="file" 的输入标签。如果我浏览并选择图像并尝试在脚本中使用$('file_upload').val()获取文件路径,它将返回路径为“C:\fakepath\img_name”
我需要获取此路径并将其设置为默认值以从 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>