Flex 调用javascript上传文件读取文件的本地路径的一直是 "C:/fakepath/" 的解决方案
2011-04-12 14:08
991 查看
主要是浏览器安全性设置的问题,可以采用以下代码解决
<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>
<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读取文件的本地路径的问题("C:/fakepath/")的解决方案
- IE8上传文件时javascript取文件的本地路径的问题(&quot;C:\fakepath\&quot;)的解决方案javascript
- IE8上传文件时javascript取文件的本地路径的问题("C:\fakepath\")的解决方案
- IE8上传文件时javascript取文件的真实路径的问题("C:\fakepath\xxxxx )
- IE8上传文件时javascript取文件的本地路径的问题("C:\fakepath ...
- IE8上传文件时文件本地路径变成"C:\fakepath\"的问题
- IE 上传文件时文件本地路径变成"C:\fakepath\"的问题
- IE8+上传文件时javascript取文件的本地路径的问题C:/fakepath/
- 解决IE8上传文件时javascript取文件的本地路径的问题C:\fakepath\..
- IE8上传文件时文件本地路径变成"C:\fakepath\"的问题
- IE8上传文件时文件本地路径变成"C:\fakepath\"的问题
- IE8上传文件时javascript取文件的本地路径的问题C:/fakepath/
- 解决IE8上传文件时javascript取文件的本地路径的问题C:\fakepath\..
- FileUpLoad选择图片后,直接将图片显示在image中。及IE8本地路径("C:/fakepath/")出现问题的解决方案
- IE8上传文件时javascript取文件的本地路径的问题C:\fakepath\
- IE8上传文件时javascript取文件的本地路径的问题C:/fakepath/
- IE8上传文件时javascript取文件的本地路径为: C:/fakepath/
- <input type="file">定义样式并获取上传文件路径及指定文件类型
- IE8上传文件时获取文件本地路径问题(C:\fakepath\……)的解决办法