jquery validate 校验 文件上传类型

由于项目开发使用到jquery validate 在校验 上传文件的时候 发现 自带的校验功能丰富,且好用。但是有些MIME由于不经常使用不太方便查看所以在此做个记录

<body>

<form class="cmxform" id="fileForm" method="post" action="">

<fieldset>

<legend>选择指定类型的文件?</legend>

<p>

<label for="file1">选择一个纯文本文件(例如 *.txt)</label>

<input type="file" id="file1" name="file1" class="required" accept="text/plain" />

</p>

<p>

<label for="file2">选择任何图像文件</label>

<input type="file" id="file2" name="file2" class="required" accept="image/*"/>

</p>

<p>

<label for="file3">选择一个 PDF 或 EPS 文件</label>

<input type="file" id="file3" name="file3" class="required" accept="image/x-eps,application/pdf"/>

</p>

<p>

<label for="file4">选择任何音频或图像文件</label>

<input type="file" id="file4" name="file4" class="required" accept="image/*,audio/*"/>

</p>

<p>

<label for="file5">选择一个或多个纯文本文件(例如 *.txt)</label>

<input type="file" id="file5" name="file5" class="required" multiple accept="text/plain" />

</p>

<p>

<input class="submit" type="submit" value="提交"/>

</p>

</fieldset>

</form>

</body>

</html> 此例子参考w3cschool。

具体的可能用到的MINIEType如下:

.dotx,application/vnd.openxmlformats-officedocument.wordprocessingml.template

.docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document

.xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

.pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation

.doc,application/msword

.dot,application/msword

.xls,application/vnd.ms-excel

.ppt - application/mspowerpoint

More > >

An official listing of defined MIME types:

.ai - application/postscript

.aif - audio/x-aiff

.aifc - audio/x-aiff

.aiff - audio/x-aiff

.asc - text/plain

.au - audio/basic

.avi - video/x-msvideo

.bcpio - application/x-bcpio

.bin - application/octet-stream

.c - text/plain

.cc - text/plain

.ccad - application/clariscad

.cdf - application/x-netcdf

.class - application/octet-stream

.cpio - application/x-cpio

.cpt - application/mac-compactpro

.csh - application/x-csh

.css - text/css

.dcr - application/x-director

.dir - application/x-director

.dms - application/octet-stream

.doc - application/msword

.drw - application/drafting

.dvi - application/x-dvi

.dwg - application/acad

.dxf - application/dxf

.dxr - application/x-director

.eps - application/postscript

.etx - text/x-setext

.exe - application/octet-stream

.ez - application/andrew-inset

.f - text/plain

.f90 - text/plain

.fli - video/x-fli

.gif - image/gif

.gtar - application/x-gtar

.gz - application/x-gzip

.h - text/plain

.hdf - application/x-hdf

.hh - text/plain

.hqx - application/mac-binhex40

.htm - text/html

.html - text/html

.ice - x-conference/x-cooltalk

.ief - image/ief

.iges - model/iges

.igs - model/iges

.ips - application/x-ipscript

.ipx - application/x-ipix

.jpe - image/jpeg

.jpeg - image/jpeg

.jpg - image/jpeg

.js - application/x-javascript

.kar - audio/midi

.latex - application/x-latex

.lha - application/octet-stream

.lsp - application/x-lisp

.lzh - application/octet-stream

.m - text/plain

.man - application/x-troff-man

.me - application/x-troff-me

.mesh - model/mesh

.mid - audio/midi

.midi - audio/midi

.mif - application/vnd.mif

.mime - www/mime

.mov - video/quicktime

.movie - video/x-sgi-movie

.mp2 - audio/mpeg

.mp3 - audio/mpeg

.mpe - video/mpeg

.mpeg - video/mpeg

.mpg - video/mpeg

.mpga - audio/mpeg

.ms - application/x-troff-ms

.msh - model/mesh

.nc - application/x-netcdf

.oda - application/oda

.pbm - image/x-portable-bitmap

.pdb - chemical/x-pdb

.pdf - application/pdf

.pgm - image/x-portable-graymap

.pgn - application/x-chess-pgn

.png - image/png

.pnm - image/x-portable-anymap

.pot - application/mspowerpoint

.ppm - image/x-portable-pixmap

.pps - application/mspowerpoint

.ppt - application/mspowerpoint

.ppz - application/mspowerpoint

.pre - application/x-freelance

.prt - application/pro_eng

时间: 2024-08-05 10:13:10

jquery validate 校验 文件上传类型的相关文章

jquery组件WebUploader文件上传用法详解

这篇文章主要为大家详细介绍了jquery组件WebUploader文件上传用法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 WebUploader是由Baidu WebFE(FEX)团队开发的一个简单的以HTML5为主,FLASH为辅的现代文件上传组件,下文来为各位演示一下关于jquery WebUploader文件上传组件的用法. 使用WebUploader还可以批量上传文件.支持缩略图等等众多参数选项可设置,以及多个事件方法可调用,你可以随心所欲的定制你要的上传组件. 接下来我以图片上

Javascript Fromdata 与jQuery 实现Ajax文件上传以及文件的删除

前端HTML代码: <!DOCTYPE html> <html> <head> <title>ajax</title> <script type="text/javascript" src="js/jquery.js"></script> <meta charset="utf-8" /> <style type="text/css&qu

Javascript Fromdata 与jQuery 实现Ajax文件上传

<!DOCTYPE html> <html> <head> <title>ajax</title> <script type="text/javascript" src="js/jquery.js"></script> <meta charset="utf-8" /> <style type="text/css"> fo

JavaScript如何判断文件上传类型 实例分享

分享下JavaScript判断文件上传类型的方法,可针对重复的内容触发onchange事件. JavaScript判断文件上传类型的方法:文件上传时用到一个功能,使用html元素的input标签实现: <input id="imageFile" name="imageFile1" accept="image/jpg,image/jpeg,image/png,image/bmp,image/gif" type="file"

struts2之限制文件上传类型

FileUploadInterceptor中定义了setAllowedExtensions(String)和setAllowedTypes(String)两种方法来限制文件上传类型 1.setAllowedExtensions(String)设置允许上传的文件后缀名, setAllowedTypes(String)设置了允许上传文件的类型,推荐使用setAllowedTypes(String). 因为如果使用setAllowedExtensions(String)用户将文件后缀修改成允许上传的后

SpringMVC全局文件上传类型限制【终极解决方案】

各位小伙伴们,有没有遇到这种情况,在信息安全日益受到各方重视的当下,白帽子越来越多,相应的作为开发人员的安全意识也得与日俱增.但是呢,总会有各种各种的原因,会出现全局性系统性的问题,你无法解决,或者无从下手.怎么办?没办法,只有回归本质. 今天分享一个SpringMVC全局文件上传类型限制终极解决方案,为那些还在迷茫该如何处理全局性文件上传漏洞的小伙伴送来一份小礼物.在阅读我的代码之前,请看下面的一篇关于SpringMVC文件上传的博文摘要.博文地址http://exceptioneye.ite

jQuery File Upload文件上传插件使用

jQuery File Upload 是一个Jquery文件上传组件,支持多文件上传.取消.删除,上传前缩略图预览.列表显示图片大小,支持上传进度条显示:支持各种动态语言开发的服务器端.官网链接:https://github.com/blueimp/jQuery-File-Upload/wiki 特点:拖放支持:上传进度条:图像预览:可定制和可扩展的:兼容任何服务器端应用平台(PHP, Python, Ruby on Rails, Java, Node.js, Go etc.). 使用方法: 1

Jquery Uploadify多文件上传实例

jQuery Uploadify开发使用的语言是java. 详细的相关文档,可以参考官网的doc:http://www.uploadify.com/documentation/ 官网的讲解还是很详细的,关键是要耐心看.虽说是英文,单有百度翻译. 看官网jQuery uploadify有基于flash和html5 的2个版本.我使用的是基于flash的. Jsp页面引用的文件有: <!-- 转诊单的附件商场页面 --> <script type="text/javascript&

jquery uploadify 多文件上传插件 使用经验

Uploadify 官网:http://www.uploadify.com/ 一.如何使用呢? 官网原文:http://www.uploadify.com/documentation/uploadify/implementing-uploadify/在我理解的基础上,做了一些翻译吧,建议直接看官网原文,因为截止到发布这篇博客为止,官方的版本是v3.2.1使用之前我们来看下使用的最低要求. 要求 jQuery 1.4.x 或更新的版本Flash Player 9.0.24 或更新的版本服务器端实现