EN
HTML - file input only for PDFs
0 points
In this article, we would like to show you how to create file input only for pdf files in HTML.
Quick solution:
xxxxxxxxxx
1
<input type="file" accept="application/pdf,application/x-pdf,application/x-bzpdf,application-gzpdf">
or:
xxxxxxxxxx
1
<input type="file" accept=".pdf">
In this example, we create file input using type="file"
attribute. To make it allow only pdf
files, we set accept
attribute to the types that file input should accept.
xxxxxxxxxx
1
2
<html>
3
<body>
4
<label>
5
<span>Choose a file:</span>
6
<input type="file"
7
name="picture"
8
accept="application/pdf,application/x-pdf,application/x-bzpdf,application-gzpdf">
9
</label>
10
</body>
11
</html>