上传文件路径问题

C:fakepath文件路径问题

今天在做导入时,不论是什么路径上传的文件,路径都变成了"C:fakepath"+文件名的形式,查询了下,两种解决方法:

1、这是ie8下的安全设置问题,以下就是操作步骤:

工具 -> Internet选项 -> 安全 -> 自定义级别 -> 找到“其他”中的“将本地文件上载至服务器时包含本地目录路径”,选中“启用”即可。

2、不用修改浏览器安全配置的javascript代码,兼容ie, firefox全系列  

 1 function getPath(obj)    
 2 {    
 3   if(obj)    
 4     {    
 5    
 6     if (window.navigator.userAgent.indexOf("MSIE")>=1)    
 7       {    
 8         obj.select();    
 9    
10       return document.selection.createRange().text;    
11       }    
12    
13     else if(window.navigator.userAgent.indexOf("Firefox")>=1)    
14       {    
15       if(obj.files)    
16         {    
17    
18         return obj.files.item(0).getAsDataURL();    
19         }    
20       return obj.value;    
21       }    
22     return obj.value;    
23     }    
24 }    
25 //参数obj为input file对象  
原文地址:https://www.cnblogs.com/zhilu-doc/p/6769840.html