(1) Use the accept attribute in the file upload. The input field in this example can accept both GIF and JPEG images:
<form> <input type="file" name="pic" id="pic" accept="image/gif, image/jpeg" /> </form>
Without limiting the format of the image, it can be written as:
accept="image/*"
(2) Definition and usage
The accept attribute can only be used with <input type="file">. It specifies the file types that can be submitted via file upload.
Tip: Avoid using this property. The file upload should be validated on the server side.