Reputation: 1765
I want an input type="file"
to accept only pdf and excel
I did this <input type="file" name="upload" accept="application/pdf,application/vnd.ms-excel" />
And it accepts .pdf and .xls files, but not .xlsx, how can I make it accept xlsx files as well?
Upvotes: 7
Views: 16177
Reputation: 5462
Try following:
<input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
In modern browser you can also use file extensions directly like:
accept=".pdf, .xls, .xlsx"
Upvotes: 14
Reputation: 143
Try using this and let me know !
<input type="file" accept=".pdf,.xls" />
EDIT Simply
<input type="file" accept="add all the extension of your choice separating by a comma " />
Upvotes: 2