Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a file field that only accept pdf and doc

I need to accept only pdf and doc file using input type file.

<input type="file" id="test" name="test" accept="application/msword,text/plain, application/pdf"/>

This is working in windows, but in ubunthu, it only accept pdf file

like image 727
Vineetha K D Avatar asked Jul 13 '15 09:07

Vineetha K D


2 Answers

Change your code to this:

<input type="file" id="test" name="test" accept=".pdf,.doc"/>

The extensions should start with a dot "." and separated by a comma ","

like image 194
Ahs N Avatar answered Oct 04 '22 10:10

Ahs N


You can try accept attribute for performing this task. Example:- <input type="file" id="example" name="test" accept=".pdf,.docx"/> Just as simple as it is.

like image 25
Himanshu Soni Avatar answered Oct 04 '22 11:10

Himanshu Soni