Well in many sites like Instagram, Facebook, WhatsApp and many more we see that file pickers are being used. When we want to implement that in our website we know that we do this:
<input type="file" />
This is ok for just a normal file picker. When you want an image file picker what do you do?? What do you do when you want to allow the users of your website to only upload images.
Use this trick:
<input type="file" accept="image/png, image/jpeg" />
What we basically are doing here is we are asking the normal file picker to only pick the files that have the extension of .png and .jpeg.
This was as easy as that and boom:
WE CAN ONLY SELECT IMAGES!!!
Thank You for reading this short blog.
Follow my IG for more coding related content: IG Link