Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open phone camera from HTML page?

Tags:

html

android

my android phone is connected to a web server through a webview. in my HTML I have a button to upload a photo. the user should have the choice to upload an image or take a photo from camera. my HTML code is:

 <div  class="takePhoto">
    <form id="take" action="" method="POST"> 
        <input type="file" id= "cap" name="personalPhoto" accept="image/*" capture ="camera" id="camera"><p>
    </form>
</div>

However when I click on the button the file chooser opens and I have the ability to choose images but not to use the camera. Any solution for this?

P.S. in my code the word (capture) doesn't have a special style or color which I find weird and this might be the problem!

like image 696
Kalkhouri Avatar asked May 30 '17 13:05

Kalkhouri


People also ask

How do you access camera in Javascript?

For this we are going to use Navigator media Devices. Navigator Media Devices: It is a read-only property that returns a Media Devices object, which helps us to access the connected media input devices like camera and microphone. Syntax : var mediaDevices = navigator.


1 Answers

In iPhone iOS6 and from Android ICS onwards, HTML5 has the following tag which allows you to take pictures from your device:

 <input type="file" accept="image/*" capture="camera">

you can also try

 <input type="file" accept="image/*" capture="capture">

or

<input type="file" accept="image/*;capture=camera">
like image 58
Abderrahim Soubai-Elidrisi Avatar answered Sep 23 '22 11:09

Abderrahim Soubai-Elidrisi