Reputation: 14773
For the mobile website of a project I need to add a image-uploading button which does allow the access of the Iphone camera. For example, the user does have his own profile and wants to add an avatar to that, he should have the possibility to make a photo, which is directly uploading to a database. Ive found some scripts where it is possible to access the photo-gallery, but i want to access the camera, which automatically uploads the picture...
Take a picture and upload
something like that! Any help is much appreciated,
Greets
Upvotes: 1
Views: 4527
Reputation: 696
For iOS < 6, you can always implement an image picker yourself and then inject the captured image data into the html as base64 encoded data.
Take the picture, base 64 encode your captured image data, then, with jQuery, it should be quite simple:
[self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"$('#imagePlaceholder').attr('src','data:image/png;base64,%@');", base64ImageDataString]];
Upvotes: 1
Reputation: 12243
If you have iOS 6 or greater you can use the
<input type="file" accept="image/*" capture="camera">
Upvotes: 3