zoukankan      html  css  js  c++  java
  • 上传时获取文件的完整路径图片预览的js代码(兼容Firfox和IE)

    http://www.lao8.org/article_1341/tougao

    <html>
        <head>
            <title>get file input full path</title>
        <script language='javascript'>
     //alert(navigator.userAgent);
            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>

  • 相关阅读:
    iOS-AVPlayer
    简单认识一下什么是闭包
    你珍惜一个人,一定是感动过
    用户关闭浏览器页器,弹出一个提示
    Html5 小球键盘移动
    HTML坦克大战学习01
    關於 WebClient wc = new WebClient() 下載第三方數據不能進安安信任異常
    封装自己的yQuery
    js彈出層或者js彈出引用url Frame 層
    动态创建表单模拟提交
  • 原文地址:https://www.cnblogs.com/byayn/p/3683500.html
Copyright © 2011-2022 走看看