【发布时间】:2012-05-29 11:47:14
【问题描述】:
我在 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>
【问题讨论】:
标签: javascript jquery html jquery-ui javascript-events