How to access a mobile's camera from a web app?
Safari & Chrome on iOS 6+ and Android 2.2+ support HTML Media Capture which allows you to take pictures with your device's camera or select an existing one:
<input type="file" accept="image/*">
Here's how it works on iOS 10:
Android 3.0+ and Safari on iOS10.3+ also support the capture
attribute which is used to jump straight to the camera.
<input type="file" accept="image/*" capture>
capture="camera"
(String) and accept="image/*;capture=camera"
(Parameter) were part of old specs and were replaced by capture
(Boolean) the W3C Candidate Recommendation.
Support documentation: this 2013 O'Reilly book and my testing
HTML5 Camera access not working in Microsoft Edge
I tried the Photo Capture using webcam demo on Edge and it is working quite fine. you can check the below screenshot.
You need to use navigator.mediaDevices.getUserMedia
. Even though Chrome 45 has navigator.mediaDevices
and a getUserMedia
function which returns a Promise, it does not accept spec-style constraints.
Note: Make sure to turn on the Camera setting "Let apps use my
camera" and from the list of apps that can use your camera turn on Microsoft Edge as well.
How can I access iPhone or Android camera using HTML5?
I don't think this is possible. At least, in the current state, HTML5 cannot access the camera (or other peripherals). An alternative would be to create a PhoneGap application, where you can develop the app in HTML5 (which will be wrapped into a native application), with additional libraries (JS) which let you access these.
More info on PhoneGap: http://phonegap.com/start
Camera api on PhoneGap: http://docs.phonegap.com/en/1.0.0/phonegap_camera_camera.md.html
Related Topics
Insert HTML with Scripts That Should Run
Is The Marquee HTML Element Supported by All Browsers Yet
Make Flex Container Take Width of Content, Not Width 100%
Font Size Extremely Small on Mobile Devices
How to Align Dt and Dd Side-By-Side Using Flexbox with Multiple Dd Underneath The Other
CSS Sprites and Repeating Backgrounds
CSS Double Border (2 Colors) Without Using Outline
How to Pass Parameters to CSS Classes
What's The Point of The <Option> "Label" Attribute Inside <Select>
How to Successfully Embed Images in HTML for Display in Webmail Clients
Justify-Content: Space-Between Failing to Align Elements as Expected
How to Get Rid of X and Up/Down Arrow Elements of a Input Date
Select Size Attribute Size Not Working in Chrome/Safari
Do You Need to Close Meta and Link Tags in HTML