zoukankan      html  css  js  c++  java
  • input File文件上传

    文件上传的类型控制选择:

        <input type="file" accept="application/msword" >

    accept属性列表:

        1.accept="application/msexcel"
        2.accept="application/msword"
        3.accept="application/pdf"
        4.accept="application/poscript"
        5.accept="application/rtf"
        6.accept="application/x-zip-compressed"
        7.accept="audio/basic"
        8.accept="audio/x-aiff"
        9.accept="audio/x-mpeg"
        10.accept="audio/x-pn/realaudio"
        11.accept="audio/x-waw"
        12.accept="image/gif"
        13.accept="image/jpeg"
        14.accept="image/tiff"
        15.accept="image/x-ms-bmp"
        16.accept="image/x-photo-cd"
        17.accept="image/x-png"
        18.accept="image/x-portablebitmap"
        19.accept="image/x-portable-greymap"
        20.accept="image/x-portable-pixmap"
        21.accept="image/x-rgb"
        22.accept="text/html"
        23.accept="text/plain"
        24.accept="video/quicktime"
        25.accept="video/x-mpeg2"
        26.accept="video/x-msvideo"

        27.accept=".apk"  //.apk为需要上传文件的后缀名,需要上传什么格式的文件,控制显示当前的文件后缀就好

        28.accept="image/*" //选择所有的图片类型

    限制图片上传大小控制示例

    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <script type="text/javascript"> 
      var isIE = /msie/i.test(navigator.userAgent) && !window.opera; 
      function fileChange(target) { 
            var fileSize = 0; 
            var filemaxsize = 1024*2;//2M 
            if (isIE && !target.files) { 
                  var filePath = target.value; 
                  var fileSystem = new ActiveXObject("Scripting.FileSystemObject"); 
                  var file = fileSystem.GetFile (filePath); 
                  fileSize = file.Size; 
            } else { 
                  fileSize = target.files[0].size; 
            }
            var size = fileSize / 1024; 
            if(size>filemaxsize){ 
                  alert("图片大小不能超过"+filemaxsize/1024+"M!"); 
                  target.value =""; 
                  return false; 
            }else if(size<=0){ 
                  alert("图片大小不能为0M!"); 
                  target.value =""; 
                  return false; 
            }else{
                  alert("上传成功!");
            }
          }
    </script> 
    </head> 
    <body> 
          <input type="file" onChange="fileChange(this);" accept="image/*"/> 
    </body> 
    </html>
  • 相关阅读:
    安卓代码混淆与反射冲突,地图无法显示等问题解决及反编译方法
    脱掉360奇虎的“加固保”壳后的发现与你的微信安全
    android 发送http请求
    mysql sql优化
    hdu 1548 A strange lift
    【转】vc中使用SendMessage正确发送自定义消息的方法--不错
    【转】各种常用浏览器“兼容性视图”设置方法
    IE 弹出"Unable to do xml/xsl" Processing
    【转】MFC界面更新实现方法
    【转】怎么在Foxmail回复/转发时使用签名?
  • 原文地址:https://www.cnblogs.com/houzhao/p/5458853.html
Copyright © 2011-2022 走看看