简体   繁体   English

从 Google 相册上传多张照片

[英]Upload multiple photos from Google Photos

The goal is to be able to select multiple photos from Google Photos on an Android device and upload them using a regular html file input control.目标是能够在 Android 设备上从 Google 相册中选择多张照片,并使用常规的 html 文件输入控件上传它们。

I am able to select multiple photos but only one is uploaded...我可以选择多张照片,但只上传了一张...

Using the Gallery I am able upload multiple photos.使用图库我可以上传多张照片。 Any idea why?知道为什么吗?

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

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

When multiple files are selected the number of selected files appears in front of the file input.选择多个文件时,将显示在文件输入前面的所选文件的数量。

EDIT 1: included the attribute accept="image/*".编辑 1:包括属性 accept="image/*"。 Still doesn't work if source of the photos is Google Photos如果照片来源是 Google 相册,仍然无法正常工作

I have experienced the same problem before. 我以前也遇到过同样的问题。 I used this line of code to bypass my problem: 我使用以下代码绕过了我的问题:

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

if you want to upload only specified file types try using: 如果您只想上传指定的文件类型,请尝试使用:

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

Same problem here. 这里同样的问题。 Google Photos picker allows multiple selection on Chrome but only returns one file. Google相册选择器允许在Chrome上进行多项选择,但仅返回一个文件。

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

There is a bug report on Chromium about this but no sign of activity: https://bugs.chromium.org/p/chromium/issues/detail?id=348912 关于Chromium的错误报告与此有关,但没有活动迹象: https : //bugs.chromium.org/p/chromium/issues/detail?id=348912

Guess we have to wait or implement a solution with the Picasa Web Albums Data API . 猜猜我们必须等待或使用Picasa网络相册数据API实施解决方案。

You should specify the input types you want to accept.您应该指定要接受的输入类型。 For whatever reason, this makes everything work as expected.无论出于何种原因,这都会使一切按预期工作。

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

Same problem here, with different versions of the 'Google Photos' App (eg 3.24.0.204162798 on Android 8.0). 使用不同版本的“ Google相册”应用(例如,Android 8.0上的3.24.0.204162798)在这里也存在同样的问题。

The respective dialog is openend on the intent and I'm able to select multiple images but only one is returned to the HTML input element. 相应的对话框在意图上是开放式的,我可以选择多个图像,但是只有一个返回到HTML输入元素。

The HTML input element I'm using is the following: 我正在使用的HTML输入元素如下:

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

I'm pretty sure that the HTML code is correct and should work, references: 我很确定HTML代码正确无误,并且可以正常工作,请参考:

Any hint is appreciated! 任何提示表示赞赏!

Edit: 编辑:

Anybody know where I can submit a bug report for Google's 'Photos' App? 有人知道我可以在哪里提交Google“照片”应用程序的错误报告吗?

The accept attribute is incredibly useful. accept属性非常有用。 It is a hint to browsers to only show files that are allowed for the current input .它提示浏览器仅显示当前input允许的文件。 While it can typically be overridden by users, it helps narrow down the results for users by default, so they can get exactly what they're looking for without having to sift through a hundred different file types.虽然它通常可以被用户覆盖,但默认情况下它有助于缩小用户的结果范围,因此他们可以准确地获得他们正在寻找的内容,而无需筛选一百种不同的文件类型。

Usage用法

Note: These examples were written based on the current specification and may not actually work in all (or any) browsers.注意:这些示例是根据当前规范编写的,可能实际上并不适用于所有(或任何)浏览器。 The specification may also change in the future, which could break these examples.规范也可能在未来发生变化,这可能会破坏这些示例。

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

For Multiple image upload对于多张图片上传

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

but from the "mobile" (image/*) input it let you select from Camera or some apps, but not Documents , and you weren't able to multi-select from them.但是从“移动”(图像/*)输入它允许您从Camera或某些应用程序中进行选择,但不能从Documents ,并且您无法从中进行多选。

so now i'm just using:所以现在我只是使用:

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

this gives me access to select from Documents and Camera but not any of the apps, but at least Documents allows you to select multiple images.这使我可以从DocumentsCamera进行选择,但不能从任何应用程序中进行选择,但至少Documents允许您选择多个图像。

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

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