在上传文件的时候,需要限制指定的文件类型。

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

accept表示可以上传文件类型,image表示图片,*表示所有支持的格式。

accept可以指定如下信息:

*.3gpp

audio/3gpp, video/3gpp

3GPP Audio/Video

*.ac3

audio/ac3

AC3 Audio

*.asf

allpication/vnd.ms-asf

Advanced Streaming Format

*.au

audio/basic

AU Audio

*.css

text/css

Cascading Style Sheets

*.csv

text/csv

Comma Separated Values

*.doc

application/msword

MS Word Document

*.dot

application/msword

MS Word Template

*.dtd

application/xml-dtd

Document Type Definition

*.dwg

image/vnd.dwg

AutoCAD Drawing Database

*.dxf

image/vnd.dxf

AutoCAD Drawing Interchange Format

*.gif

image/gif

Graphic Interchange Format

*.htm

text/html

HyperText Markup Language

*.html

text/html

HyperText Markup Language

*.jp2

image/jp2

JPEG-2000

*.jpe

image/jpeg

JPEG

*.jpeg

image/jpeg

JPEG

*.jpg

image/jpeg

JPEG

*.js

text/javascript, application/javascript

JavaScript

*.json

application/json

JavaScript Object Notation

*.mp2

audio/mpeg, video/mpeg

MPEG Audio/Video Stream, Layer II

*.mp3

audio/mpeg

MPEG Audio Stream, Layer III

*.mp4

audio/mp4, video/mp4

MPEG-4 Audio/Video

*.mpeg

video/mpeg

MPEG Video Stream, Layer II

*.mpg

video/mpeg

MPEG Video Stream, Layer II

*.mpp

application/vnd.ms-project

MS Project Project

*.ogg

application/ogg, audio/ogg

Ogg Vorbis

*.pdf

application/pdf

Portable Document Format

*.png

image/png

Portable Network Graphics

*.pot

application/vnd.ms-powerpoint

MS PowerPoint Template

*.pps

application/vnd.ms-powerpoint

MS PowerPoint Slideshow

*.ppt

application/vnd.ms-powerpoint

MS PowerPoint Presentation

*.rtf

application/rtf, text/rtf

Rich Text Format

*.svf

image/vnd.svf

Simple Vector Format

*.tif

image/tiff

Tagged Image Format File

*.tiff

image/tiff

Tagged Image Format File

*.txt

text/plain

Plain Text

*.wdb

application/vnd.ms-works

MS Works Database

*.wps

application/vnd.ms-works

Works Text Document

*.xhtml

application/xhtml+xml

Extensible HyperText Markup Language

*.xlc

application/vnd.ms-excel

MS Excel Chart

*.xlm

application/vnd.ms-excel

MS Excel Macro

*.xls

application/vnd.ms-excel

MS Excel Spreadsheet

*.xlt

application/vnd.ms-excel

MS Excel Template

*.xlw

application/vnd.ms-excel

MS Excel Workspace

*.xml

text/xml, application/xml

Extensible Markup Language

*.zip

aplication/zip

Compressed Archive

input type=file accept中可以限制的文件类型的更多相关文章

  1. <input type="file" />浏览时只显示指定文件类型

    <input type="file" />浏览时只显示指定文件类型 <input type="file" accept="appli ...

  2. input type=file accept中文件格式限制

    原文链接:https://blog.csdn.net/usuallyuser/article/details/83060341 accept="application/msexcel,app ...

  3. input输入框type=file时accept中可以限制的文件类型(转载)

    转载自: input type=file accept中可以限制的文件类型 在上传文件的时候,需要限制指定的文件类型. <input type="file" accept=& ...

  4. input type="file" accept="image/*"上传文件慢的问题解决办法

    相信大家都写过<input type="file" name="file" class="element" accept=" ...

  5. <input type="file"> accept属性筛选文件类型

    如果你不希望用户上传任何类型的文件, 你可以使用 input 的 accept 属性. 设置支持 .doc / .docx / .xls / .xlsx / .pdf 格式: <input ty ...

  6. 【转】input file accept属性可以限制的文件类型

    来源:http://blog.sina.com.cn/s/blog_6c9d65a10101a8yh.html 在上传文件的时候,需要限制指定的文件类型. <input type="f ...

  7. HTML5中的input type为file控件限制上传文件类型及扩展

    简单介绍 input file控件限制上传文件类型如下:1.文件类型中间用,分开:2.html和htm这样的要写成两个: 3实例: <input type="file" na ...

  8. 关于input type=file上传图片的总结

    最近比较忙,现在来整理一下近期的成果,方便以后再次使用. 关于图片上传的js 和jq jq $("input").change(function () { var $file = ...

  9. input type=file 选择图片并且实现预览效果的实例

    为大家带来一篇input type=file 选择图片并且实现预览效果的实例. 通过<input />标签,给它指定type类型为file,可提供文件上传: accept:可选择上传类型, ...

随机推荐

  1. 封装对Cookie和Session设置或取值的类

    public class CookieHelper : System.Web.SessionState.IReadOnlySessionState    { public static void Se ...

  2. git 的记住用户名和密码和一些常用

    git config --global core.autocrlf falsegit config --global color.ui truegit config --global credenti ...

  3. 运行phpize时出现:Cannot find autoconf. Please check your autoconf installation

    运行/usr/local/webserver/php/bin/phpize时出现:Configuring for:PHP Api Version: 20041225Zend Module Api No ...

  4. UITouch触摸事件

    UITouch触摸事件 主要为三个方法 1.-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{2.3. UITouch * ...

  5. cocos2dx 资源合并.

    文件合并之前 文件合并之后 吐槽 我们项目比较奇葩, ui用cocostudio做, 这项光荣的任务由美术接手. 这个美术是个新手, 经过我长时间的观察, 她似乎不用怎么画画. 至少在很长一段时间里, ...

  6. rhel安装eclipse

    smb --> IDE --> 环境gcc(开发c) g++(开发c++)c++操作linux --> sqlite数据库linux平台自带sqlite数据库 基本SQL语言划分:D ...

  7. svn更新

    下载配置文件 pwd cd /home/www/xxxx/protected/config/ get main.php 上传配置文件 put main.php svn更新 svn co svn://s ...

  8. Adb shell 常用命令

    1. 查看IP adb shell netcfg 2. 查看挂载设备 adb devices 3. 将本地端口转发至手机端口 adb forward tcp: tcp: // PC上所有6100端口通 ...

  9. Java学习----方法的重载

    一个类中有多个同名的参数不一样的方法. 作用:可以根据不同的条件调用不同的方法. 注意:java不会因为方法的返回类型或者权限的不同而判断为不同的两个方法. public class Student ...

  10. 超级易使用的jquery视频背景插件Vide

    http://www.jqcool.net/demo/201410/jquery-vide/ 官网: http://vodkabears.github.io/vide/