Home > Web Front-end > HTML Tutorial > html input="file" 浏览时只显示指定文件类型 xls、xlsx、csv_html/css_WEB-ITnose

html input="file" 浏览时只显示指定文件类型 xls、xlsx、csv_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 08:59:08
Original
1280 people have browsed it

Valid Accept Types:

For CSV files (.csv), use: 

<input type="file" accept=".csv" />
Copy after login

For Excel Files 2003-2007 (.xls), use:

<input type="file" accept="application/vnd.ms-excel" />
Copy after login

For Excel Files 2010 (.xlsx), use:

<input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
Copy after login

For Text Files (.txt) use:

<input type="file" accept="text/plain" />
Copy after login

For Image Files (.png/.jpg/etc), use:

<input type="file" accept="image/*" />
Copy after login

For HTML Files (.htm,.html), use:

<input type="file" accept="text/html" />
Copy after login

For Video Files (.avi, .mpg, .mpeg, .mp4), use:

<input type="file" accept="video/*" />
Copy after login

For Audio Files (.mp3, .wav, etc), use:

<input type="file" accept="audio/*" />
Copy after login

For PDF Files, use:

<input type="file" accept=".pdf" /> 
Copy after login

DEMO:
http://jsfiddle.net/dirtyd77/LzLcZ/144/

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template