Lizz Parody
Lizz Parody

Reputation: 1765

Input type='file' accept pdf and excel file extension

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

Answers (2)

Anshuman Jaiswal
Anshuman Jaiswal

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

Raja Osama
Raja Osama

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

Related Questions