File Inputs
Certain filetypes or mime types can be accepted using the normal file input 'input[type="file"]'.
Say you want to restrict access to PDF files only. You can achieve this by setting the input's accept
attribute.
<input type="file" accept="application/pdf">
Your window will only enable selecting PDF files when it is triggered via the file input.
For example try clicking the file input above.
You can either use the mimetype string like application/pdf
or use the file extension like .pdf
. Multiple allowed filetypes are separated with a comma.
You can also use wildcards like image/*
.
<input type="file" accept="application/pdf, .pdf, image/*">
- Next: CSS Grid and forms.
- Previous: HTML2Canvas