码迷,mamicode.com
首页 > Web开发 > 详细

jquery validate 校验 文件上传类型

时间:2015-03-02 19:15:04      阅读:480      评论:0      收藏:0      [点我收藏+]

标签:jqueryvalidate 校验 文件

由于项目开发使用到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


jquery validate 校验 文件上传类型

标签:jqueryvalidate 校验 文件

原文地址:http://blog.csdn.net/x734400146/article/details/44020295

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!