39

Is there a JavaScript API for accessing the the iPhone's camera from Mobile Safari?

kim3er
  • 6,306
  • 4
  • 41
  • 69

4 Answers4

100

Since iOS6, you can use

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

It will act like a regular file upload, but instead, it will open the iPhone camera and upload a picture or a video.

Hope this help someone.

Simon Arnold
  • 15,849
  • 7
  • 67
  • 85
  • 3
    This should be the accepted answer, since the old one isn't correct anymore. – Johannes Klauß Nov 19 '13 at 08:28
  • 3
    Can I somehow remove the `Choose Existing` button? I want the video to be uploaded directly from camera only. – Adil Malik Apr 17 '14 at 14:27
  • Good question @AdilMalik! Unfortunately, not that I'm aware of, but if you find a way, let me know. – Simon Arnold Apr 17 '14 at 14:47
  • As an addendum to this, it looks like HTML5 offers some interesting ways to get webcam images/video: http://www.html5rocks.com/en/tutorials/getusermedia/intro/ – Joel B Oct 27 '14 at 18:01
5

You can via http://picupapp.com/

It is a Free iPhone App and JS that can convert an upload box into a button that requests the app, along with instructions to the App on where to post the image...

This thing should get an award.

Now if only we could get them to also make it work perfect with Android and Blackberry.

Mason
  • 59
  • 1
  • 2
  • 1
    Think about it. The person is trying to make a mobile version of a web site that has the ability to capture images from a phone's camera. I'm pretty sure that people accessing a web app wouldn't be exclusively iOS users. – Mateo Jan 23 '12 at 17:21
  • Answer to old comment, but relevant. This is why you wouldn't need it for Android http://hacks.mozilla.org/2012/04/taking-pictures-with-the-camera-api-part-of-webapi/ – subhaze Jul 25 '12 at 00:44
3

There is a specification from the W3C which would allow this, although to my knowledge none has implemented it yet: http://www.w3.org/TR/2010/WD-html-media-capture-20100928/

Simon Arnold
  • 15,849
  • 7
  • 67
  • 85
James Westgate
  • 11,306
  • 8
  • 61
  • 68
1

Chrome and Safari on iOS7 can access the Camera and the Camera Roll without any special markup and can perform both AJAX POST and synchronous form POST operations just like a desktop browser.

Raj
  • 3,791
  • 5
  • 43
  • 56