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


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。