Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use Google Chrome 11's Upload Folder feature in my own code?

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.

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.

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!

like image 723
Peter Avatar asked Apr 28 '11 23:04

Peter


People also ask

How do I change the upload folder in Chrome?

The change is virtually seamless, as Chrome users will simply be presented with two options when clicking “Upload”. All you have to do is click “Upload a Folder”, choose the folder you want to upload, and click “Select”. The entire folder structure and all files will be uploaded through the browser.

How do I create a link to a folder in Chrome?

To add an existing bookmark to a folder:From the Bookmark Manager, click and drag a bookmark into the the desired folder. The bookmark will appear in the folder. You can open the bookmark from Bookmark Manager or the Other bookmarks folder on the Bookmarks bar.


Video Answer


1 Answers

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

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

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

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

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.

like image 158
Kinlan Avatar answered Sep 21 '22 09:09

Kinlan