HTML accept attribute
You can limit the upload file type in HTML <input type="file"> using the [accept] attribute.
For Example, If you want to allow PDF files only, You can specify it by the below code:
<input type="file" accept=".pdf">
Now, with this code, only PDF files can be uploaded.
If you want to to allow multiple file types e.g. [.jpg, .jpeg, .png]. You can achieve this by the below code:
<input type="file" accept=".png, .jpg, .jpeg">
And so on you can specify your desired file type to upload.
Also read, How to download files in the desired extension
This post was modified 2 years ago 2 times by CodeWithBishal-admin