在用到weboffice控件上传文件附件的时候,出现了C:\fakepath\的问题,就是有的机器能够上传,有的机器不能上传,这个问题首先跟IE的设置有关系。 在用到webObj.HttpAddPostFile("attachment", document.getElementById("attachment").value);出现文件上传不能上传问题。 首先能够经过修改浏览器的安全级别,步骤是: 工具 -> Internet选项 -> 安全 -> 自定义级别 -> 找到“其余”中的“将本地文件上载至服务器时包含本地目录路径”,选中“启用”便可。 固然上述的方法确定不可取,总不能让每个用户都修改ie配置吧,下面给出一种用js代码修改的方法 兼容ie ,firefox全系列 Javascript代码 function getPath(obj) if(obj) { if (window.navigator.userAgent.indexOf("MSIE")>=1) { obj.select(); return document.selection.createRange().text; } else if(window.navigator.userAgent.indexOf("Firefox")>=1) { if(obj.files) { return obj.files.item(0).getAsDataURL(); } return obj.value; } return obj.value; } 修改后代码: webObj.HttpAddPostFile("attachment", getPath(document.getElementById("attachment")));