How to make a file field that only accept pdf and doc
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.
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 ","