Get HTML5 Camera and Video on iPhone
One of the questions I get asked most often via my contact form is how to get access to the camera and video recorder on the iPhone from within the browser. It's a valid question, one that I've not come across in the needs of my own website, but since I get it so often, I thought I'd address it. Of course the camera is an input of the device, but the
INPUT element is the key to camera and video access with HTML5.
In the case of both camera and video, the
INPUT element with a type of
file is necessary:
<input type="file" accept="image/*">
To isolate only a photos as the type to be uploaded, the
accept attribute must match the pattern above.
If you're looking to be more dynamic and accept video, the
accept attribute will need to change:
<input type="file" accept="video/*;capture=camcorder">
In this case, the upload dialog on the iOS device will allow you to upload either photos or video.
This still seems like a far too basic method of uploading audio or video but it is probably good enough for most developers and systems. In the future we'll have a much better method for taking dynamic audio and video without the ugly upload dialog!