直接上代码 记录一下

 

1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
 5 <title>get file input full path</title> 
 6     <script language='javascript'> 
 7 function getFullPath(obj) 
 8         { 
 9 if(obj) 
10             { 
11 //ie 
12 if (window.navigator.userAgent.indexOf("MSIE")>=1) 
13                 { 
14                     obj.select(); 
15 return document.selection.createRange().text; 
16                 } 
17 //firefox 
18 else if(window.navigator.userAgent.indexOf("Firefox")>=1) 
19                 { 
20 if(obj.files) 
21                     { 
22 return obj.files.item(0).getAsDataURL(); 
23                     } 
24 return obj.value; 
25                 } 
26 return obj.value; 
27             } 
28         } 
29 </script> 
30     </head> 
31     <body> 
32         <input type="file" onchange="document.getElementById('img').src=getFullPath(this);" /> 
33     <img id="img" /> 
34     </body> 
35 </html>

 

firefox7+请使用return window.URL.createObjectURL(obj.files.item(0));来获取地址