如何在我自己的代码中使用 Google Chrome 11 的上传文件夹功能? [英] How do I use Google Chrome 11's Upload Folder feature in my own code?

查看:25
本文介绍了如何在我自己的代码中使用 Google Chrome 11 的上传文件夹功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google Chrome 11 现在支持上传文件夹.目前此功能仅在 Google Docs 中实现,我无法在我的代码中找到有关如何使用此功能的任何 API 文档.

Google Chrome 11 now supports uploading folders. Currently this feature is only implemented in Google Docs, and I have been unable to find any API documentation on how to use this in my code.

据我所知,您单击 Google Docs 中的上传文件夹链接,该链接显示浏览文件夹"对话框(从外观上调用 SHBrowseForFolder),您选择一个文件夹,然后选择其中的内容该文件夹已上传到 Google 文档.

From what I can see, you click the Upload folder link in Google Docs, which displays the "Browse For Folder" dialog (a call to SHBrowseForFolder by the looks of it), you select a folder, and then the contents of that folder is uploaded to Google Docs.

由于此功能需要将 Google Chrome 升级到最新版本,或者对于运行 Java Applet 的其他浏览器,我假设我可以在自己的网站中使用此功能?

As this feature requires upgrading Google Chrome to the latest version, or for other browsers running a Java Applet, I assume I can use this feature in my own websites?

我希望在我维护的内容管理系统中拥有此功能!

I would love to have this feature in a Content Management System I maintain!

推荐答案

您应该可以在这里看到演示:http://html5-demos.appspot.com/static/html5storage/demos/upload_directory/index.html

You should be able to see a demo here: http://html5-demos.appspot.com/static/html5storage/demos/upload_directory/index.html

基本上它通过在文件输入元素上设置属性webkitdirectory"来工作.

Basically it works by setting up an attribute "webkitdirectory" on a file input element.

<input type="file" id="file_input" webkitdirectory="" directory="">

然后当用户选择一个文件夹时,它会遍历e.target.files"对象以获取包含在选择中的文件列表(这使您可以从客户端访问这些文件).

Then when the user has selected a folder, it itterates across the "e.target.files" object to get a list of files included in the selection (this enables you to have access to those files from the clientside).

拖放是类似的,当你在一个draggable"元素上监听ondrop"事件时,如果一个目录或选择的文件被拖放到该元素上,事件上的files"属性将是一个操作中包含的文件列表.

Drag and drop is similar, when you listen to the "ondrop" event on a "draggable" element, if a a directory or selection of files is dropped on to the element, the "files" property on the event will be a list of files contained in the operation.

这篇关于如何在我自己的代码中使用 Google Chrome 11 的上传文件夹功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆