在IE8中上傳路徑變成了C:\fakepath\*,主要原因是因為微軟又體貼了用戶一把,如何解決呢?
1 工具 -> Internet選項 -> 安全 -> 自定義級別 -> 找到“其他”中的“將本地文件上載至服務(wù)器時包含本地目錄路徑”,選中“啟用”即可。
2
<script type="text/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;
}
}
//以下即為完整客戶端路徑
var filepath=getPath(document.getElementById("iptfileupload"));
</script>