【发布时间】:2011-04-26 14:01:12
【问题描述】:
我正在构建一个模块,用户可以在其中发布他们的数据。 我有几个文本字段和一张图片,通过 HTML 输入控件上传时需要预览。
我的方法:
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插件?? 或者我们可以检索隐藏字段内的路径,因为这是防止从文件输入中检索路径的安全措施??
【问题讨论】: