HTML File Upload Doesn't Show Gallery on Android

。_饼干妹妹 提交于 2019-12-05 13:05:41

问题


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.


回答1:


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

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

It works for me.




回答2:


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



来源:https://stackoverflow.com/questions/24470932/html-file-upload-doesnt-show-gallery-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!