In the page Preview client local picture of the JS code (compatible with FF IE) _ Image effects

Source: Internet
Author: User
The company recently had a project with this kind of demand I just found out what I wrote before how to get user local picture path through JS The method used in this article only supports local page preview local picture
One solution is to go back to the server and return a relative path, but efficiency is a problem, and the complexity of programming can increase
Directly on the demo code for more have this kind of demand and suffer from not find the solution of the peer to provide the source reproduced please specify the source I have more solutions for other problems here for more people to refer to
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/> <title>get file input full path</title> <script type=" Text/javascript "J Avascript ' > Function GetFullPath (obj) {var newpreview = document.getElementById ("img"); if (obj) {//ie if (window.navigator.userAgent.indexOf ("MSIE") >= 1) {obj.select (); NewPreview.style.filter = "Progid:DXImageTransform.Microsoft.AlphaImageLoader (Sizingmethod=scale);"; NewPreview.filters.item ("DXImageTransform.Microsoft.AlphaImageLoader"). src = Document.selection.createRange (). Text Return }//firefox else if (window.navigator.userAgent.indexOf ("Firefox") >= 1) {if (obj.files) {newpreview.src = window . Url.createobjecturl (Obj.files.item (0)); Return } newpreview.src = Obj.value; Return } newpreview.src = Obj.value; Return } </script> </pead> <body> <input type= "file" onchange= "GetFullPath (this);"/> </body > </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

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.