<script> function Setimagepreview () {var Docobj=document.getelementbyid ("Doc");
var Imgobjpreview=document.getelementbyid ("Preview"); if (Docobj.files && docobj.files[0]) {//Firefox, set the img attribute directly Imgobjprevie
W.style.display = ' block ';
ImgObjPreview.style.width = ' 300px ';
ImgObjPreview.style.height = ' 120px ';
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, use the filter Ocobj.select ();
var imgsrc = Document.selection.createRange (). text;
var localimagid = document.getElementById ("Localimag"); The initial size must be set localImagId.style.width = "250px";
LocalImagId.style.height = "200px"; Image of the exception to capture, to prevent users to modify the suffix to forge pictures try{localimagid.style.filter= "progid:DXImageTransform.Microsof
T.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> <body> <input type=file name= "Doc" id= "Doc" onchange= "Javascript:setimagepreview ();" > <p><div id= "Localimag" > </div> </p>