我想在将图像上传到服务器之前预览图像。我已经为它编写了一些代码,但由于某种类型的安全原因,它只能在 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>