Just use the accept
:
<form action="/action_page.php">
<input type="file" name="pic" accept="image/*">
<input type="submit">
</form>
To determine the type, you need to know a little about Mime-Types. In the example above, any image serves.
Could have used image/jpeg
, for example, if you wanted to restrict more.
As answered by @DVD, in your case the syntax is this:
<input type='file' required accept="image/*, application/pdf">
Separating desired types by comma.
Basic examples:
text/plain
text/html
image/jpeg
image/png
audio/mpeg
audio/ogg
audio/*
video/mp4
application/octet-stream
Learn more about Mime-Types here:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basico_sobre_HTTP/MIME_types
Round, thanks for the help!
– ElvisP
@DVD I think valid restore your.
– Bacco