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.
The input element, having the "file" value in its type attribute, represents a control to select a list of one or more files to be uploaded to the server. When the form is submitted, the selected files are uploaded to the server, along with their name and type.
The <input type="file"> defines a file-select field and a "Browse" button for file uploads. To define a file-select field that allows multiple files to be selected, add the multiple attribute.
Try to use <input name="userfile" type="file" accept="image/*" />
instead of <input name="userfile" type="file" accept="images/*" />
.
It works for me.
Turns out this is a known bug in Android >= 4.4. My code works as expected in iOS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With