For security purposes, IE does not allow the page to preview local images on the client. That is, the SRC of the img element cannot be an absolute path.
Filters are required to meet this requirement.
The company recently has a project with such a demand I found that I previously wrote how to get the user's local image path through JS http://www.bkjia.com/kf/201205/132513.html the method used in this article only supports local Page Preview local Images
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">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> get file input full path </title>
<Script type = "text/javascript" language = 'javascript '>
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>
</Head>
<Body>
<Input type = "file" onchange = "getFullPath (this);"/>
</Body>
</Html>
From AhJesus