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:
// ONLINE-RUNNER:browser;
<input type="file" accept="application/pdf,application/x-pdf,application/x-bzpdf,application-gzpdf">
or:
// ONLINE-RUNNER:browser;
<input type="file" accept=".pdf">
Practical example
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.
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<body>
<label>
<span>Choose a file:</span>
<input type="file"
name="picture"
accept="application/pdf,application/x-pdf,application/x-bzpdf,application-gzpdf">
</label>
</body>
</html>