zoukankan      html  css  js  c++  java
  • 获取 input[type=file] 文件上传尺寸

    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head runat="server">  
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
        <title></title>  
    </head>  
    <body>  
        <form id="form1" runat="server">  
            <div>  
                <input type="file" name="f" id="f" />  
                <input type="button" name="aa" id="aa" value="测试" onclick="javascript: _s();" />  
            </div>  
        </form>  
    </body>  
    </html>  
    <script type="text/javascript">  
        function _s() {  
            var f = document.getElementById("f").files;  
            //上次修改时间  
            alert(f[0].lastModifiedDate);  
            //名称  
            alert(f[0].name);  
            //大小 字节  
            alert(f[0].size);  
            //类型  
            alert(f[0].type);  
        }  
    </script>
    
    
    判断文件类型
    var type=(src.substr(src.lastIndexOf("."))).toLowerCase();
      if(type!=".jpg"&&type!=".gif"&&type!=".jpeg"&& type!=".png"){
      alert("您上传图片的类型不符合(.jpg|.jpeg|.gif|.png)!");
      return false;
    }
    

      

  • 相关阅读:
    C++
    复盘-2018.6.8~2020.6.8
    C++
    C++
    C++
    C++
    Python学习笔记(十)- 面向对象(一)
    SSHException: Error reading SSH protocol banner
    docker 安装mysql
    docker 安装部署
  • 原文地址:https://www.cnblogs.com/yugb/p/10053241.html
Copyright © 2011-2022 走看看