Html file input accept only images


The accept attribute specifies a filter for what file types will be accepted.

Accept Only Image Files
<input type="file" name="img" accept="image/png, image/gif, image/jpeg" />
Accept Only Pdf Files
<input type="file" name="myfile" accept="application/pdf" />
Attribute Values
  • audio/*   Accept any audio file.
  • video/*   Accept any video file.
  • image/*  Accept any image file.

Complete list of standard media types. Click