$("#file_upload"). Change (function () {var$file = $ ( This); varFileobj = $file [0]; varWindowurl = window. URL | |Window.webkiturl; varDataurl; var$img = $ ("#preview"); if(Fileobj && fileobj.files && fileobj.files[0]) {Dataurl= Windowurl.createobjecturl (fileobj.files[0]); $img. attr ('src', Dataurl); } Else{Dataurl=$file. Val (); //$img. CSS ("filter", ' progid:DXImageTransform.Microsoft.AlphaImageLoader (Sizingmethod = scale,src= "' + Dataurl + ') )‘); //var imgobj = document.getElementById ("preview"); //imgObj.style.filter = "Progid:DXImageTransform.Microsoft.AlphaImageLoader (sizingmethod=scale,src=\" "+ Dataurl + "\")"; //imgObj.style.width = "48px"; //imgObj.style.height = "48px"; varImgobj = document.getElementById ("Preview"); //two pits://1, when the Filter property is set, the element must already exist in the DOM tree, the dynamically created node, also need to be added to the DOM before setting the property, first set the attribute is added, invalid;//2, the SRC attribute needs to be added as follows, the above two ways to add, invalid;ImgObj.style.filter ="Progid:DXImageTransform.Microsoft.AlphaImageLoader (Sizingmethod=scale)"; ImgObj.filters.item ("DXImageTransform.Microsoft.AlphaImageLoader"). src =Dataurl; } });
Front-End Code:
<input id= "file_upload" type= "file"/>
<div class= "Image_container" id= "Previewdiv" >
</div>
Internet Explorer upload Picture preview compatible (ie 7 8 9 10 11)