我正在构建一个模块,其中用户可以发布他们的数据。 我有几个文本字段和一个图像,当通过HTML输入控件上传需要预览。获取jquery中的文件输入值
我的方法:
HTML部分:
<div class="divClass" id="FirstAd">
<h4 align="center">
Advertisement 1</h4>
<div style="float: left; width:25%">
<img src="images.jpg" id="replaceMe" width="100px" height="130px" /></div>
<div style="float: right; width:70%; left:30%">
<input type="text" style="width: 197px" /><br />
<br />
<textarea class="AdContent"></textarea><br />
<br />
<input type="file" id="myImage" size="30" onchange="pictureUpload()" /><br />
<input type="button" value="Preview!"/><br/>
</div>
</div>
第j查询部分:
function pictureUpload() {
$(document).ready(function() {
var imagepath = "file:\\" + $("#myImage").val();
$("#replaceMe").attr("src", imagepath);
alert(imagepath);
});
}
我能先手与扩展没有路径的文件名。
有没有其他选择? 或一些jquery插件? 或我们可以检索隐藏字段内的路径,因为它是一种安全措施,以防止从文件输入中检索路径?
这应该是一条评论。 – Pavlo 2012-11-06 09:50:44