I want my uploader only allows these types:
- doc, docx.
- xls, xlsx.
- ppt, pptx.
- txt.
- pdf.
- Image types.
How can I achieve this? What should I put in the accept
attribute? Thanks for your help.
EDIT!!!
I have one more thing to ask. When the popup appears for use to choose file, at the down right corner, there is a drop down list contains all allow files. In my case, the list would be long. I see in the list, there is an option called All Supported Types
. How can I make it chosen by default and eliminate all other options?
Any help will be appreciated. Thank you.
IMPORTANT UPDATE:
Due to use of only application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint... allows only till 2003 MS products, and not newest. I've found this:
And that includes the new ones. For other files, you can retrieve the MIME TYPE in your file by this way (pardon the lang)(in MIME list types, there aren't this ones):
You can select & copy the type of content
for powerpoint and pdf files:
Use Like below
Use accept attribute with the MIME_type as values
for image write this
For other, You can use the accept attribute on your form to suggest to the browser to restrict certain types. However, you'll want to re-validate in your server-side code to make sure. Never trust what the client sends you
As stated on w3schools: