[Html] <script> function setImagePreview () {var docObj = document. getElementById ("doc"); var imgObjPreview = document. getElementById ("preview"); if (docObj. files & docObj. files [0]) {// under Firefox, set the img attribute imgObjPreview directly. style. display = 'block'; imgObjPreview. style. width = '300px '; imgObjPreview. style. height = '120px '; // imgObjPreview. src = docObj. files [0]. getAsDataURL (); // Firefox 7 or later versions cannot be obtained using the getAsDataURL () method. ImgObjPreview. src = window. URL. createObjectURL (docObj. files [0]);} use the filter docObj under else {// IE. select (); var imgSrc = document. selection. createRange (). text; var localImagId = document. getElementById ("localImag"); // The initial size must be set to localImagId. style. width = "250px"; localImagId. style. height = "200px"; // capture Abnormal images to prevent users from modifying the suffix to counterfeit images. try {localImagId. style. filter = "progid: DXImageTransform. microsoft. alphaImageLoader (si ZingMethod = scale) "; localImagId. filters. item ("DXImageTransform. microsoft. alphaImageLoader "). src = imgSrc;} catch (e) {alert ("the format of the image you uploaded is incorrect. Please reselect it! "); 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>