My company recently had a project with this requirement. I found that the method I used in this article to get the local image path of users through JS only supports preview of local images on the local page.
One solution is to return relative paths after uploading to the server, but the efficiency is a problem, and the programming complexity will be improved.
Directly use the demo code to provide source code reprinted for more peers who have such requirements but cannot find a solution. Please indicate the source. I have more solutions to other problems for your reference.
<! 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> </pead> <body> <input type =" file "onchange =" getFullPath (this ); "/> </body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]