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]