On Android devices, if you want to create a file input that prompts the
user to either choose an image from their photo album or take a picture with their
camera, you'll need this basically undocumented capture
attribute added to your input's accept
property:
<input type="file" accept="image/*;capture=camera" />
On iOS, the operating system will always show an image picker and the camera
with a type="file"
input even if it doesn't have the ;capture=camera
directive.
Also note, this attribute only does anything on mobile operating systems, this won't change the behavior of your inputs for desktop clients.
A final note: if you add a capture
property
to a file input, like this:
<input type="file" accept="image/*" capture="environment" />
...this tells the browser to prefer camera capture over an image picker.
The values can be "environment"
or "user"
.