wangdahai
<HTML>  
    <head>  
        <script type="text/javascript" src="script/jquery-1.6.2.min.js"></script>  
        <script type=\'text/javascript\'>  
            function selectFile(){  
                //触发 文件选择的click事件  
                $("#file").trigger("click");  
  
            //其他code如 alert($("#file").attr("value"))  
            }  
              
            /* 获取 文件的路径 ,用于测试*/  
            function getFilePath(){  
                alert($("#file").attr("value"));  
            }  
        </script>  
    </head>  
    <body>  
        <!-- 给这个input 设置样式隐藏,切忌不可用display控制隐藏,可能不能跨浏览器 -->  
        <input type="file" id="file" onchange="getFilePath()"   
            style="filter:alpha(opacity=0);opacity:0;width: 0;height: 0;"/>   
        <button onclick="selectFile();">select file</button>  
        <button onclick="getFilePath()">get FilePath</button>  
    </body>  
</html> 

 

分类:

技术点:

相关文章:

  • 2021-11-19
  • 2021-09-19
  • 2021-11-01
  • 2021-11-01
  • 2021-12-26
  • 2021-10-19
  • 2021-12-29
猜你喜欢
  • 2021-10-29
  • 2021-05-12
  • 2021-09-19
  • 2021-11-03
  • 2021-11-01
  • 2021-08-02
  • 2021-11-02
相关资源
相似解决方案