文件上传C:\fakepath\解决方案

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

2.利用js代码:

function getFilePath(input){  
    if(input){//input是<input type="file">Dom对象  
        if(window.navigator.userAgent.indexOf("MSIE")>=1){  //如果是IE    
            input.select(); 
       input.blur();
return document.selection.createRange().text; } else if(window.navigator.userAgent.indexOf("Firefox")>=1){ //如果是火狐 { if(input.files){ return input.files.item(0).getAsDataURL(); } return input.value; } return input.value; } }

 

参考:http://blog.csdn.net/panzuhong234234/article/details/51198843

      https://www.zhihu.com/question/31728280

posted @ 2018-01-10 16:35  H.U.C-王子  阅读(954)  评论(0编辑  收藏  举报