【发布时间】:2011-05-04 21:17:49
【问题描述】:
我想在将图像上传到服务器之前对其进行预览。我已经为它编写了一些代码,但由于某种安全原因,它只能在 Internet Explorer 中预览,而不是在 Safari、Chrome、Firefox 等其他浏览器中预览。有没有办法在这些浏览器中预览图片?
<body>
<form name="Upload" enctype="multipart/form-data" method="post">
Filename: <INPUT type="file" id="submit">
<INPUT type="button" id="send" value="Upload">
</form>
<div
id="div"
align="center"
style="height: 200px;width: 500px;border-style: ridge;border-color: red">
</div>
</body>
<script type="text/javascript">
var img_id=0
var image = new Array()
document.getElementById('send').onclick=function()
{
img_id++
var id="imgid"+img_id
image = document.getElementById('submit').value;
document.getElementById('div').innerHTML="<img id='"+id+"' src='"+image+"' width=500px height=200px>"
}
</script>
</html>
【问题讨论】:
标签: javascript