js传真实地址 C:fakepath

js给action传真是地址的时候,处于安全,传到action中 浏览器会改变路径变为C:fakepathftp.txt,但是原始路径却是

C:Documents and SettingsAdministrator桌面ftp.txt

下面就是获得原始路径的方法

var url = getPath(document.getElementByIdx_x("url"))
function getPath(obj) {
 if (obj) {
  //注意,MSIE是在ie10之前可以用滴,在ie11以后trident哦,参考:http://www.cnblogs.com/wolfocme110/p/4630819.html
  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;
 }
}
原文地址:https://www.cnblogs.com/wolfocme110/p/4630868.html