欢迎来到刘认真的博客

It's not me that's wrong. It's the whole world

js 上传图片预览

 

js 上传图片预览

 1 <script type="text/javascript">
 2     //选择图片,马上预览
 3     function xmTanUploadImg(obj) {
 4         var file = obj.files[0];
 5         var reader = new FileReader();
 6         reader.onload = function(e) {
 7             var img = document.getElementById("img1");
 8             img.src = e.target.result;
 9         }
10         reader.readAsDataURL(file);
11     }
12 </script>

 

 

1               <TD class=field>图  片:</TD>
2               <TD><INPUT class=text type=file name=houseImage accept=".jpg,.png" onchange="xmTanUploadImg(this)"></TD></TR>
3             <TR>
4             <tr>
5               <th></th>
6               <td><input type="image" id="img1" style="width: 60px; height: 50px;"></td>
7             </tr>

 

posted @ 2019-08-07 16:20  刘认真  阅读(318)  评论(0编辑  收藏  举报