日期:2014-05-17  浏览次数:20500 次

JavaScript获取FileUpload上传文件的全路径 的问题,在不更改浏览器设置的情况下。
 
<html>
    <head>
        <title>get file input full path</title>
    <script language='javascript'>
        function getFullPath(obj)
        {
            if(obj)
            {
                //ie
                if (window.navigator.userAgent.indexOf("MSIE")>=1)
                {
                    obj.select();
                    return document.selection.createRange().text;
                }
                //firefox
                else if(window.navigator.userAgent.indexOf("Firefox")>=1)
                {
                    if(obj.files)
                    {
                        return obj.files.item(0).getAsDataURL();
                    }
                    return obj.value;
                }
                return obj.value;
            }
        }
    </script>
    </head>
    <body>
        <input type="file" onchange="document.getElementById('img').src=getFullPath(this);" />
    <img id="img" />
    </body>
</html>


这种方法好似不得行了,网上也找寻了很多。
没有找到,有人说
目前已经不能通过js获取选定文件的全路径,为了安全起见。
一般现在采用本地预览都是flash的方式。

真的是这样吗?没有其他解决办法了么?