解决IE8上传文件时javascript取文件的本地路径的问题C:\fakepath\..
2011-03-31 11:03
751 查看
IE8上传文件时javascript读取文件的本地路径的问题("C:\fakepath\")的解决方案
前一阵把IE6升级到了IE8,没想到一个网站里面的上传图片时用JavaScript预览本地图片的功能失效了,图片总是显示错误,用alert()看了下图片的路径居然变成了C:\fakepath\*.jpg,真实的路径被C:\fakepath\取代了,于是在网上开始找解决方案。
<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>
前一阵把IE6升级到了IE8,没想到一个网站里面的上传图片时用JavaScript预览本地图片的功能失效了,图片总是显示错误,用alert()看了下图片的路径居然变成了C:\fakepath\*.jpg,真实的路径被C:\fakepath\取代了,于是在网上开始找解决方案。
<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>
相关文章推荐
- 解决IE8上传文件时javascript取文件的本地路径的问题C:\fakepath\..
- IE8上传文件时javascript取文件的本地路径的问题(&quot;C:\fakepath\&quot;)的解决方案javascript
- IE8上传文件时获取文件本地路径问题(C:\fakepath\……)的解决办法
- IE8上传文件时javascript取文件的本地路径的问题("C:\fakepath ...
- IE8上传文件时javascript读取文件的本地路径的问题("C:/fakepath/")的解决方案
- IE8上传文件时javascript取文件的本地路径的问题C:\fakepath\
- IE8上传文件时javascript取文件的本地路径的问题("C:\fakepath\")的解决方案
- IE8上传文件时javascript取文件的本地路径的问题C:/fakepath/
- IE8上传文件时获取文件本地路径问题(C:\fakepath\……)的解决办法
- IE8上传文件时javascript取文件的本地路径的问题C:/fakepath/
- IE8上传文件时获取文件本地路径问题(C:\fakepath\……)的解决办法
- IE8上传文件时javascript读取文件的本地路径的问题("C:/fakepath/")的解决方案
- IE8上传文件时文件本地路径变成"C:\fakepath\"的问题
- IE8上传文件时文件本地路径变成"C:\fakepath\"的问题
- IE8+上传文件时javascript取文件的本地路径的问题C:/fakepath/
- IE8上传文件时文件本地路径变成"C:\fakepath\"的问题
- IE8上传文件时javascript取文件的真实路径的问题("C:\fakepath\xxxxx )
- IE8上传文件时javascript取文件的本地路径为: C:/fakepath/
- IE8 用滤镜实现上传预览图片,解决C:\fakepath\*.jpg问题,获取本地路径
- IE浏览器上传文件时本地路径变成”C:\fakepath\”的问题