html accept file types excel code example

Example: input accept excel html

Add accept attribute to the input :
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"

<input type="file" name="file" id="file" class="form-control" required accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel">

Other input types :

CSV files (.csv): accept=".csv"

Excel Files 97-2003 (.xls): accept="application/vnd.ms-excel"

Excel Files 2007+ (.xlsx): accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" 

Text Files (.txt): accept="text/plain"

Image Files (.png/.jpg/etc): accept="image/*"

HTML Files (.htm,.html): accept="text/html"

Video Files (.avi, .mpg, .mpeg, .mp4): accept="video/*"

Audio Files (.mp3, .wav, etc): accept="audio/*"

PDF Files: accept=".pdf"

Tags:

Html Example