js 文件路径的获取,包括火狐,IE

var obj=$("#xiaozhangPic")[0];
var filepath ="";
 if (window.navigator.userAgent.indexOf("MSIE") >= 1) {
    obj.select();
    filepath = document.selection.createRange().text;
} else if (window.navigator.userAgent.indexOf("Firefox") >= 1) {
    if (obj.files) {
        filepath =  obj.files.item(0).getAsDataURL();
    }
    else
    {
        filepath = obj.value;
    }
}       

   

注: 火狐的地址是火狐编码后的地址, 不是实际的文件地址, 不影响使用.

  ie下的是实际地址即使IE8也是获取实际地址的.

原文地址:https://www.cnblogs.com/henw/p/2171378.html