码迷,mamicode.com
首页 > 编程语言 > 详细

IE8上传文件时javascript读取文件的本地路径的问题("C:\fakepath\")的解决方案

时间:2015-10-13 10:37:08      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:

    <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\")的解决方案

标签:

原文地址:http://www.cnblogs.com/mandalaluo/p/4873486.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!