js代码
//该函数解决iE下路径问题。兼容ie6,7,firefox
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;
}
}
调用方式
var imgup = document.getElementById("uploadimg");
var imgpath = getPath(imgup);
其他版本请自行改造并测试