我有一个移动网页,其中包括类型文件的input元素,允许用户将图像文件上传到服务器。该网页能正常工作在iOS上,和一台Nexus 4(安卓4.2.1)在Chrome浏览器。
I have a mobile web page which includes an input element of type 'file', to allow users to upload image files to a server. The page works fine on iOS, and on a Nexus 4 (Android 4.2.1) in the Chrome Browser.
当我使用的是三星S3(安卓4.0.4)上的选择文件按钮默认的浏览器点击打开,如预期的图像选择对话框中,我选择一个图像,并关闭该对话框的网页被刷新后,但,所以我失去了所选择的图像。有其他人看到这种行为?有什么建议的解决办法?
When I use a Samsung S3 (Android 4.0.4) with the default browser clicking on the 'Choose file' button opens the image selection dialog as expected, however after I choose an image and close the dialog the web page gets refreshed, so I lose the image that was selected. Has anyone else seen this behaviour? Any suggestions for a workaround?
这是我正在使用的输入元素是相当标准,而且看起来是这样的:
The input element that I'm using is fairly standard, and looks like this:
<input id="addPhoto" type="file" accept="image/*"/>
即使没有'接受'属性我得到了同样的问题。
Even without the 'accept' attribute I get the same problem.
有一个看起来这个问题:
Have a look a this issue:
https://$c$c.google.com/p/android/issues/detail?id=53088
基本上,似乎是发生是这样的:
Basically, what seems to be happening is this:
Android不具备足够的内存可用于文件选择器或摄像头应用程序。
Android does not have enough memory available for the file-chooser or camera app.
它通过关闭浏览器释放内存
It frees up memory by closing the browser
在文件选择器/相机关闭时,浏览器再次被打开,触发页面刷新,这使得整个文件选择锻炼没用。
After the file chooser/camera is closed the browser is opened again, triggering a page refresh, which renders the whole file choosing exercise useless.
在我看来,这是超出了任何基于浏览器的解决方案的控制,但我很乐意被证明是错误的这个假设
It seems to me that this is beyond the control of any browser based solution but I would love to be proven wrong on this assumption.