Internet Explorer upload Picture preview compatible (ie 7 8 9 10 11)

Source: Internet
Author: User

$("#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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.