相关疑难解决方法(0)

如何在通过JavaScript上传之前上传预览图像

我想在将图像上传到服务器之前预览图像.我为它编写了一些代码,但由于某些安全原因,它只是在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>
Run Code Online (Sandbox Code Playgroud)

javascript

9
推荐指数
1
解决办法
5万
查看次数

标签 统计

javascript ×1