Languages
[Edit]
EN

JavaScript - capture image from device camera using input HTML element (mobile devices only)

10 points
Created by:
Zayaan-Rasmussen
543

In this short article, we would like to show how capture image from mobile device camera using input HTML element and JavaScript.

Mobile web browsers introduced capture attribute in <input type="file" accept="image/*" /> HTML element that can be used to handle image directly from mobile device camera. The idea is simple: instead of file selector, web browser runs camera application forwarding result into web browser input field.

Capture attribute accepts values:

  • capture="user" that enables facing camera,
  • capture="environment" that enables outward camera.

Practical example:

 

See also

Edit
  1. JavaScript - capture video from device camera using input HTML element (mobile devices only)

References

Edit
  1. HTML attribute: capture - MDN Docs

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join