HTML文件上传没有在Android上显示图片库

时间:2021-10-11 07:09:08

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:

我想让我的PHP应用接受从移动用户的图库中选择的照片。我正在用Chrome对Android 4.4.4进行测试。这是我的形式:

<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:

我尝试过三种不同的类型="file"输入,但没有一种可以让我选择Gallery:

  <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.

是否有一些直接的方法让Gallery作为一个选项出现,或者我是否有使用JavaScript做一些环路的事情?谢谢你的答案。

2 个解决方案

#1


5  

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

尝试使用

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

而不是

It works for me.

它适合我。

#2


3  

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

在Android >= 4.4中,这是一个已知的错误。我的代码在iOS中可以正常工作。

#1


5  

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

尝试使用

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

而不是

It works for me.

它适合我。

#2


3  

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

在Android >= 4.4中,这是一个已知的错误。我的代码在iOS中可以正常工作。