Input type="file" take a photo option

13,567

Solution 1

Tried adding capture attribute to input element ?

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

See Polyfill file input with accept capture (using getUserMedia to capture?) , Capturing Audio & Video in HTML5

Solution 2

I'm wondering why camera/select-file behavior differs between the same browser on different platforms (Android Chrome vs iPhone Chrome)?

Chrome on iOS is actually just a wrapper around Webkit, Safari's rendering engine.

on iPhone Modernizr.getusermedia === false, but on <input type="file" /> menu Chrome/Safari propose me to make a photo/video.

Those are two different APIs. getUserMedia is a complex JavaScript API not implemented by Safari, while <input type="file" accept="image/*"/> is a very simple HTML5 API.

Share:
13,567
VB_
Author by

VB_

Updated on June 05, 2022

Comments

  • VB_
    VB_ almost 2 years

    I'm wondering why camera/select-file behavior differs not only between browsers (Chrome, Safari), but also between the same browser on different platforms (Android Chrome vs iPhone Chrome)?

    Modernizr.getusermedia returns true for Chrome on Android, but false for Chrome on iPhone.

    Problem: on iPhone Modernizr.getusermedia === false, but on <input type="file" /> menu Chrome/Safari propose me to make a photo/video.

    Question: is there any way to take under JavaScript control that behaviour?