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

上传文件的类型;具体作法以下所示:html

注意:accept属性能够限制上传格式,其有兼容性以下app

 

《1》上传.csv格式的ide

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

《2》上传.xls格式orm

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

《3》上传.xslx格式htm

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

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

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

《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">

注意:以逗号分隔开

相关文章
相关标签/搜索