0

I want to open mobile camera when I clicked a button from browser. Below there is an image what i want to do. This is an image what i have now

I can choose file from local and also want to add from camera.

<form action="" method="post" enctype="multipart/form-data">  
           <input type="file" name="uploadedfile" accept="image/*" capture="camera">  
           <input type="submit" value="Upload">  
        </form>

I tried above code for opening camera and it is from How to access a mobile's camera from a web app? . Now please help me to show camera on mobile through Browser.

liming
  • 202
  • 3
  • 15
  • Possible duplicate of [How to open phone camera from HTML page?](https://stackoverflow.com/questions/44264211/how-to-open-phone-camera-from-html-page) – EGC Oct 25 '19 at 02:22
  • It looks similar but I don't want from app. I want to open camera on browser only. – liming Oct 25 '19 at 02:28

1 Answers1

0

With an input[type="file"] field you can pick a file, or ask the device to record a media. It will always open an app or a prompt to choose an app. If you want to stay in the browser you need to use the MediaStream Recording API but it is not fully supported yet. For now, it is not working in iOS so either way, you have to open up the default camera app.

If you want to take photos you can try the MediaStream Image Capture API. But it is still just an experimental technology which won't work in most of the current browsers.

You can find some examples here:

I hope the links above can help you

ikarasz
  • 233
  • 2
  • 9
  • Hi, do you have any experience with mediastream image capture API? – liming Oct 31 '19 at 08:23
  • I've played with it already but only for practice. However, I have work experience with videos without leaving the browser. – ikarasz Oct 31 '19 at 09:08
  • Hi, Ikarasz. Can you share your experience with me? – liming Oct 31 '19 at 09:25
  • I have extended the answer with some links, hopefully it will help. You can find demo pages in the first two links, like: https://simpl.info/imagecapture/ – ikarasz Oct 31 '19 at 09:47
  • Thank you. If you need some others, I can help you. You can call me here. Thanks again – liming Oct 31 '19 at 17:22
  • I checked simpl.info/imagecapture. And on my local I can't run it. I have to make some details on my local, I think. Do you know what I have to do? – liming Nov 01 '19 at 03:40
  • Did you try it in chrome? As the page says it works only in chrome – ikarasz Nov 01 '19 at 05:17