A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

Directory Upload

aliams
2015-08-12

Websites are currently able to provide functionality for uploading files by using <input type="file" multiple> and drag and drop. However, there currently is no standard and interoperable spec that enables the handling of directories and cases that involve a mix of files and directories.

We are proposing a spec that will provide the necessary mechanisms to enable directory uploading which can be found here: https://wicg.github.io/directory-upload/proposal.html

This has been worked on by Microsoft - with contributions from Mozilla - and we would like to get feedback from the wider WICG before we are able to migrate it to a working group in the W3C. A polyfill that uses the old Chrome FileSystem API - which has since been deprecated - can be found here: https://wicg.github.io/directory-upload/index.html

Your feedback to our proposal is greatly appreciated!

AshleyScirra
2015-08-13

I’m concerned about how getFilesAndDirectories() appears to require loading all the File objects in to memory along the way. As it stands it looks like if you just want to examine the file/folder structure, you can’t do that without inadvertently loading every File along the way as well, and some might be quite large. So for example if a web app wants to validate that a particular directory structure is valid, it looks like with this proposal it would be unable to avoid possibly significant amounts of file I/O to load File objects that are not yet wanted or needed. Perhaps the browser could return the file tree synchronously (just file names and directory structure), and then a promise-based method would be used to retrieve each File?

Also are there any security implications around users selecting their root system directory? For example if a Windows user selects C:\ as the directory, obviously you may not want to upload that, but now JS has access to their entire system disk structure, right? (Subject to user and app permissions of course, but probably includes all their personal documents)

jwatt
2015-08-18

The size of a DOM File object doesn’t depend on the size of the file’s contents on disk. The contents typically will not be read from disk unless you create a FileReader.

AshleyScirra
2015-08-18

Oh, sounds good. In that case I think it’s fine :sunglasses:

jwatt
2015-08-18

Firefox Nightly builds currently have an implementation of the proposal for testing purposes. The implementation will be disabled in Aurora and Beta builds until the proposal is solid enough to ship at some point in the future.