Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<input accept="image/*;capture=camera"... allows any file type on mobile

Tags:

html

iphone

How do I restrict image browse button to images only white allowing drop-down menu to choose from camera, library, file on mobile?

Here's what's happening:

When using <input type="file" accept="image/*;capture=camera"> I get the drop-down I need but it doesn't restrict image file type - it can be anything (*.*)

enter image description here

When using <input type="file" accept="image/*" capture> it's image only but there's no drop-down. Camera opens directly.

How do I get the drop-down + image/*?

Demo for mobile. (Mostly needed for iPhone):

<p>Drop-down for camera, library, files but all files allowed:</p>
<input type="file" accept="image/*;capture=camera">

<p>Only images allowed but doesn't have drop-down. Opens camera directly:</p>
<input type="file" accept="image/*" capture>

Currently, I'm using JS to restrict non-images but wanted to know if there's a html5 native way.

like image 693
Miro Avatar asked Sep 12 '25 15:09

Miro


1 Answers

Figured it out minutes after asking 🙄

It's supposed to be a comma , not semi-colon ;

<p>Drop-down and Images only</p>
<input type="file" accept="capture=camera,image/*">

enter image description here

Why are most articles and tutorials using ; is beyond me :)

like image 94
Miro Avatar answered Sep 14 '25 05:09

Miro