40

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

2

4 Answers 4

101

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.

4
  • 3
    This should be the accepted answer, since the old one isn't correct anymore. Commented Nov 19, 2013 at 8:28
  • 3
    Can I somehow remove the Choose Existing button? I want the video to be uploaded directly from camera only.
    – Adil Malik
    Commented Apr 17, 2014 at 14:27
  • Good question @AdilMalik! Unfortunately, not that I'm aware of, but if you find a way, let me know. Commented Apr 17, 2014 at 14:47
  • As an addendum to this, it looks like HTML5 offers some interesting ways to get webcam images/video: html5rocks.com/en/tutorials/getusermedia/intro
    – Joel B
    Commented Oct 27, 2014 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.

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
    Commented Jan 23, 2012 at 17:21
  • Answer to old comment, but relevant. This is why you wouldn't need it for Android hacks.mozilla.org/2012/04/…
    – subhaze
    Commented Jul 25, 2012 at 0: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/

2
  • 7
    Phonegap allows you to build native apps, it won't help for accessing from the web via Safari.
    – jriskin
    Commented Nov 10, 2011 at 5:45
  • Modified the answer which was incorrent. Commented Dec 1, 2013 at 21:17
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.

1
  • 1
    Just by using standard HTML file input type: <form action="POST"> <input type="file" name="pic"> <input type="submit"> </form>
    – Raj
    Commented Oct 6, 2014 at 13:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.