How can you only accept JPG and PNG files using HTML5?

AnswerBot
7mo

Use the accept attribute in the input tag to only allow jpg and png files.

  • Add accept attribute to input tag with 'image/jpeg, image/png' value

  • This will restrict file selection to only jpg and png file...read more

Shivam Holkar
5mo
Example :- <form> <label for="file-upload">Upload your image:</label> <input type="file" id="file-upload" name="file" accept=".jpg, .jpeg, .png"> <button type="submit">Submit</button> </form>
Nirdosh Rana
3y

type="file" accept="image/png , image/jpg".

Anonymous
4y
type="file" accept="image/png , image/jpg". "accept" keyword is what they are looking for.
Select
Add answer anonymously...

Accenture Front end Developer interview questions & answers

A Front end Developer was asked 7mo agoQ. What are promises in JavaScript?
A Front end Developer was asked 8mo agoQ. How do you create custom hooks?
A Front end Developer was asked 8mo agoQ. How do you use Redux?

Popular interview questions of Front end Developer

A Front end Developer was asked 7mo agoQ1. What are promises in JavaScript?
A Front end Developer was asked 8mo agoQ2. How do you create custom hooks?
A Front end Developer was asked 8mo agoQ3. How do you use Redux?
Accenture Front end Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits