This article mainly introduces the implementation of the pictures selected without the refresh preview, the need for friends can refer to the following
The code is as follows code as follows: <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns=" http://www.w3.org/1999/xhtml "> <head> <meta http-equiv=" Content-type "content=" text/html; Charset=utf-8 "/> <title> Untitled document </title> <script type=" Text/javascript "> // Local picture preview function Setimagepreview (fieldupload, image, Imagediv) { var docobj = document.getElementById ( Fieldupload); var imgobjpreview = document.getElementById (image); if (docobj.files && docobj.files [0]) { //Firefox, Direct set img properties imgObjPreview.style.display = ' block '; imgObjPreview.style.width = ' 150px '; ImgObjPreview.style.height = ' 150px '; //imgobjpreview.src = Docobj.files[0].getasdataurl (); // Firefox 7 version can not be used above the Getasdataurl () way to obtain, need a way IMGOBJPREVIEW.SRC = window. Url.createobjecturl (Docobj.files[0]); } else { //ie, using filters Docobj.select (); var imgsrc = Document.selection.createRange () .text; var localimagid = document.getElementById (IMAGEDIV); //must set Initial size LocalImagId.style.width = "150px"; LocalImagId.style.height = "150px"; //Picture exception capture to prevent users from modifying suffixes to forge pictures Try { localImagId.style.filter = "ProgID :D XImageTransform.Microsoft.AlphaImageLoader (Sizingmethod=scale) "; LocalImagId.filters.item ("DXImageTransform.Microsoft.AlphaImageLoader"). src = imgsrc; } catch (e) { alert ("The picture you uploaded is not in the correct format, please choose again!"); return false; } imgObjPreview.style.display = ' None '; document.selection.empty (); } return true; } </script> </head> <body> <div id= " Localimag "> <img id=" Preview "width=" 150px "height=" 150px "src=" http://images.cnblogs.com/cnblogs_com/ Yc-755909659/559257/o_%e6%9a%82%e6%97%a0%e5%9b%be%e7%89%87.gif "alt=" "/></div> <div> <input type= "File" Onchange= "Javascript:setimagepreview (' upload ', ' preview ', ' Localimag ');" id= "Upload"/> </div> </body> </html>