15

I'd like my PHP app to accept a photo chosen from a mobile user's gallery. I'm testing on Android 4.4.4 using Chrome. This is my form:

<form enctype="multipart/form-data" action="index.php" method="POST">
  <input type="hidden" name="MAX_FILE_SIZE" value="20000000" />
  <input type="submit" value="Add" />
</form>

I've tried three different type="file" inputs and none of them give me the Gallery as an option:

  <input name="userfile" type="file" />

Options: Camera, Camcorder, Sound Recorder and Documents

  <input name="userfile" type="file" accept="images/*" />

Options: Camera and Documents

  <input name="userfile" type="file" accept="images/*" capture />

Goes straight into Camera.

Is there some straight-forward way to get Gallery to come up as an option or do I have do some round-about thing using JavaScript? Thanks for your answers.

Jared
  • 303
  • 1
  • 2
  • 10
  • 'the Gallery' is an app. What you get now are file pickers for folders i think. Very different. For what you want you have to start that app. And that app has to store results for your page. Well i dont know how to do that. Or is Camera the app? – greenapps Jun 29 '14 at 13:58
  • Php app using browser Chrome? Do you mean the new Chromium WebView? – greenapps Jun 29 '14 at 14:01
  • No, I mean it's a PHP app running on a regular web server and I'm connecting to it using Chrome running on Android. When I connect to the web server using a desktop browser it works as I'd expect. – Jared Jun 29 '14 at 17:22
  • You mean php scripts on a webserver. – greenapps Jun 29 '14 at 17:27

3 Answers3

12

Try to use <input name="userfile" type="file" accept="image/*" />

instead of <input name="userfile" type="file" accept="images/*" />.

It works for me.

Jeffrey Bosboom
  • 13,313
  • 16
  • 79
  • 92
Szmulik
  • 241
  • 1
  • 4
  • 10
3

Turns out this is a known bug in Android >= 4.4. My code works as expected in iOS.

Jared
  • 303
  • 1
  • 2
  • 10
0

I found a solution on my Android-Device. Google Chrome had not the right to access the Gallery (Files and Media). If you turn it through Settings->Apps->Chrome on, it works quite well.

I know it's an old thread, but I hope my answer helps others out of the struggle.

Tobias Münch
  • 829
  • 4
  • 13