[whatwg] Directory upload via <input type="file" directory>

Jonas Sicking jonas at sicking.cc
Wed Apr 28 11:29:27 PDT 2010

On Wed, Apr 28, 2010 at 11:03 AM, John Gregg <johnnyg at google.com> wrote:
>>> Also, I do believe the ability to upload a whole directory is important for
>>> some good use-cases, e.g. upload a directory of photos to a photo site while
>>> maintaing directory structure.
>> I can't really say that I can think of any very urgent use cases for
>> this. However only a minor tweak to specs would cover this. By
>> allowing the filename to contain a partial path you'd have this
>> covered without need for new input types. I think this has been
>> discussed before.
> Yes, the path information can be stored and communicated with a small
> tweak, let's take that as settled.
> Assuming the use case is valid to upload an entire directory while
> maintaining directory structure, how should the user choose the
> directory?  That's the point I'm interested in settling and I think
> we've mostly just circled around it.
> Suggestions include:
> - Open up a system folder-picker dialog.  The UA needs to know when to
> open that dialog instead of a file-picker dialog, the two dialogs
> being different on all major platforms, and so we could:
>    - use a new 'directory' attribute on <input> to indicate it (my
> original proposal)
>    - use multiple buttons (add file(s)/add folder/remove) with each
> <input multiple> that allows the user to do different things
> - Create a new file-picker for <input multiple> that allows both file
> and folder selection (i think most people want to avoid this)
> - Ojan's proposal: allow a folder to be dragged onto a <input
> multiple> tag, but don't allow specifying through dialogs.
> Clearly there are options without the new attribute, but I still think
> they all result in awkward UI.  I don't think allowing drag and drop
> only would be sufficient especially considering accessibility.

Ok. I'd recommend experimenting with this in chrome. It seems like the
most backwards compatible way would be to add another boolean
attribute like you suggest. This would then enable another button in
the UI for picking a directory. It would also make it so that partial
paths are included if a directory is dropped on the <input multiple>.

For what it's worth, I think the Mac file picker can be made to
choosing either a folder or a file. So there a <input type=file
multiple directory> would just need one button which brings up a
filepicker that allows selecting either a file or a folder.

/ Jonas

More information about the whatwg mailing list