[whatwg] Forms: <input type=file> and directory tree picking

Jonas Sicking jonas at sicking.cc
Thu Aug 29 15:06:02 PDT 2013

On Thu, Aug 29, 2013 at 2:45 PM, Ian Hickson <ian at hixie.ch> wrote:
> On Thu, 29 Aug 2013, Jonas Sicking wrote:
>> On Thu, Aug 29, 2013 at 1:20 PM, Ian Hickson <ian at hixie.ch> wrote:
>> > On Fri, 2 Aug 2013, Jonathan Watt wrote:
>> >>
>> >> I'm working on Mozilla's implementation of <input type=file> to allow
>> >> the user to pick a directory. The idea would be that the files in
>> >> that directory and its subdirectories would be added to the
>> >> HTMLInputElement.files FileList.
>> >
>> > This seems to be dangerous in that it makes it really easy for the
>> > user to select a single item that expands into tens of thousands if
>> > not millions of files on a remote disk, which then all have to be
>> > synchronously enumerated to get the count so that code can then itself
>> > enumerate through the entire list.
>> We don't have to do any enumeration synchronously. It can all happen off
>> the main thread. The .click() "API" is asynchronous.
> It's asynchronous to the JS, sure, but at the end of the day the user
> can't get any work done until it's complete. It's synchronous as far as
> the user is concerned.

Sure. The alternative is that the user attaches each file separately.
Which, while means smaller "synchronous" actions, is not really a
better UX. In other words, synchronousness is not the only design
constraint here.

>> > So you wouldn't be able to pick a file and a directory as in the
>> > example above? That seems unfortunate...
>> Unfortunately most OSs doesn't have support for filepickers that can
>> select either a file or a directory.
> True. From a UI perspective it's kind of weird that the user has to decide
> which he wants, though. Similarly, from an authoring perspective, I don't
> understand how I would decide whether to show a multiple file picker or a
> directory picker.

You display two buttons in the website UI, one for "pick file" and one
for "pick directory". We don't really have a choice as long as we live
under the two constraints of:

* Websites wants to do their own "pick" UI
* OSs can't display pickers which allow picking either a file or a directory.

/ Jonas

More information about the whatwg mailing list