HTML Input=“file” Accept Attribute File Type (CSV) - Stack Of Codes


Sunday, 11 February 2018

HTML Input=“file” Accept Attribute File Type (CSV)

HTML Input=“file” Accept Attribute File Type (CSV)

<input id="fileSelect" type="file" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/" /> 

# Selective File types to upload / chosen

Valid Accept Types:
For CSV files (.csv), use: 

<input type="file" accept=".csv" />
For Excel Files 97-2003 (.xls), use: 

<input type="file" accept="application/" />
For Excel Files 2007+ (.xlsx), use: 

<input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
For Text Files (.txt) use: 

<input type="file" accept="text/plain" />
For Image Files (.png/.jpg/etc), use: 

<input type="file" accept="image/*" />
For HTML Files (.htm,.html), use:

<input type="file" accept="text/html" />
For Video Files (.avi, .mpg, .mpeg, .mp4), use:

<input type="file" accept="video/*" />
For Audio Files (.mp3, .wav, etc), use:

<input type="file" accept="audio/*" />
For PDF Files, use:

<input type="file" accept=".pdf" /> 


If you are trying to display Excel CSV files (.csv), do NOT use:

text/comma-separated-values (works in Opera only).
If you are trying to display a particular file type (for example, a WAV or PDF), then this will almost always work...

 <input type="file" accept=".FILETYPE" />

No comments:

Post a Comment


PHP (27) CodeIgniter (22) SQL (4) Facebook (3) HTML (3) Blogger (2) Constructor (2) Destructor (2) Google (2) Aadhaar (1) Agent (1) Browser (1) CSS (1) Cakephp (1) Constants (1) How to (1) India (1) Ip address (1) JS (1) Jquery (1) Meta Tags (1) Robots (1) Scraping Data (1) escape_str (1) htaccess (1) iS mobile (1) javascript (1) mysqli (1)