繁体   English   中英

从 Google 相册上传多张照片

[英]Upload multiple photos from Google Photos

目标是能够在 Android 设备上从 Google 相册中选择多张照片,并使用常规的 html 文件输入控件上传它们。

我可以选择多张照片,但只上传了一张...

使用图库我可以上传多张照片。 知道为什么吗?

这是一个测试人员: https : //jsfiddle.net/7sL1v46e/

<input id="fileInput" type="file" multiple accept="image/*">

选择多个文件时,将显示在文件输入前面的所选文件的数量。

编辑 1:包括属性 accept="image/*"。 如果照片来源是 Google 相册,仍然无法正常工作

我以前也遇到过同样的问题。 我使用以下代码绕过了我的问题:

<input type="file" id="fileInput" multiple accept="image/*">

如果您只想上传指定的文件类型,请尝试使用:

<input type="file" id="fileInput" multiple accept="image/*,.jpg,.png"/>

这里同样的问题。 Google相册选择器允许在Chrome上进行多项选择,但仅返回一个文件。

Firefox尚不支持多个文件选择: https : //caniuse.com/#feat=input-file-multiple

关于Chromium的错误报告与此有关,但没有活动迹象: https : //bugs.chromium.org/p/chromium/issues/detail?id=348912

猜猜我们必须等待或使用Picasa网络相册数据API实施解决方案。

您应该指定要接受的输入类型。 无论出于何种原因,这都会使一切按预期工作。

<input type="file" id="images" multiple accept="image/*" />

使用不同版本的“ Google相册”应用(例如,Android 8.0上的3.24.0.204162798)在这里也存在同样的问题。

相应的对话框在意图上是开放式的,我可以选择多个图像,但是只有一个返回到HTML输入元素。

我正在使用的HTML输入元素如下:

<input id="file" type="file" accept="image/*" multiple></input>

我很确定HTML代码正确无误,并且可以正常工作,请参考:

任何提示表示赞赏!

编辑:

有人知道我可以在哪里提交Google“照片”应用程序的错误报告吗?

accept属性非常有用。 它提示浏览器仅显示当前input允许的文件。 虽然它通常可以被用户覆盖,但默认情况下它有助于缩小用户的结果范围,因此他们可以准确地获得他们正在寻找的内容,而无需筛选一百种不同的文件类型。

用法

注意:这些示例是根据当前规范编写的,可能实际上并不适用于所有(或任何)浏览器。 规范也可能在未来发生变化,这可能会破坏这些示例。

<h1>Match all image files (image/*)</h1>
<p><label>image/* <input type="file" accept="image/*"></label></p>

<h1>Match all video files (video/*)</h1>
<p><label>video/* <input type="file" accept="video/*"></label></p>

<h1>Match all audio files (audio/*)</h1>
<p><label>audio/* <input type="file" accept="audio/*"></label></p>

<h1>Match all image files (image/*) and files with the extension ".someext"</h1>
<p><label>.someext,image/* <input type="file" accept=".someext,image/*"></label></p>

<h1>Match all image files (image/*) and video files (video/*)</h1>
<p><label>image/*,video/* <input type="file" accept="image/*,video/*"></label></p>

对于多张图片上传

<input type="file" id="deviceCamera" multiple accept="image/*"/>

但是从“移动”(图像/*)输入它允许您从Camera或某些应用程序中进行选择,但不能从Documents ,并且您无法从中进行多选。

所以现在我只是使用:

<input type="file" multiple accept="image/*,.jpg,.gif,.png,.jpeg"/>

这使我可以从DocumentsCamera进行选择,但不能从任何应用程序中进行选择,但至少Documents允许您选择多个图像。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM