• input accept属性限制文件上传格式


    上传文件的类型;具体做法如下所示:

    注意:accept属性可以限制上传格式,其有兼容性如下

    《1》上传.csv格式的

    <input text="file" accept=".csv" />

    《2》上传.xls格式

    <input text="file"  accept="application/vnd.ms-excel"/>

    《3》上传.xslx格式

    <input text="fiel" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"/>

    《4》上传.png/.jpg/etc格式

    <input type="file" accept="text/plain" />

    《5》上传图片格式

    <input type="file" accept="image/*" />

    《6》上传.htm,.html格式

    <input type="file" accept="text/html" />

    《7》上传video(.avi, .mpg, .mpeg, .mp4)格式

    <input type="file" accept="video/*" />

    《8》上传audio(.mp3, .wav, etc)格式

    <input type="file" accept="audio/*" />

    《9》上传.pdf格式

    <input type="file" accept=".pdf" />

    《10》如果限制两种文件格式,同时限制

    <input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel">

    注意:以逗号分隔开

  • 相关阅读:
    C语言左移和右移
    mmap详谈
    eclipse插件自动生成类图
    async 和 defer 的区别
    SVN里恢复到某一天的版本操作
    解决跨域的jsonp+Java实例
    HTTP请求行、请求头、请求体等
    ajax在什么情况下会走success和error
    记阅读POST与GET的区别
    记一些快捷键
  • 原文地址:https://www.cnblogs.com/mmzuo-798/p/9685994.html
Copyright © 2020-2023  润新知