VikingGoat
VikingGoat

Reputation: 477

Previewing and Uploading images on smartphones

I'm trying to write a script that will allow a user to upload a picture taken by (or selected from) their phone when on my jquerymobile driven site. I've found that AJAX doesn't allow file submissions in a form and I will have to use the following line

<form method=”POST” enctype=”multipart/form-data” action=”process_update.php” data-ajax=”false”>

for the form itself, but I can't find anyway to tell the smartphone to prompt the user to choose between selecting a photograph on their phone or taking a new one.

How do I accomplish this? Would I be better off looking into using some sort of plugin?

I plan on performing cropping and size changes on the server side as part of the form submission.

Upvotes: 0

Views: 1423

Answers (1)

Kirk B.
Kirk B.

Reputation: 456

When using a Samsung Galaxy S II device's browser (webkit = 534.30) and the following form:

<form method="POST" enctype="multipart/form-data" action="process_update.php">
  <input type="file" accept="image/*; capture=camera" />
  <input type="submit" />
</form>

The device prompts me to choose camera or gallery when pressing the file input button. I believe it's the accept="image/*..." attribute that's triggering this behavior in webkit.

Upvotes: 1

Related Questions