[whatwg] File API features in HTML5

Jonas Sicking jonas at sicking.cc
Thu Aug 6 20:41:35 PDT 2009


On Thu, Aug 6, 2009 at 4:43 PM, Ian Hickson<ian at hixie.ch> wrote:
> With Arun's announcement of a stable File API spec [1], I have now updated
> HTML5 to handle the use cases listed below.
>
> [1] http://dev.w3.org/2006/webapi/FileUpload/publish/FileAPI.html
>
> On Thu, 22 Jun 2006, ivan vadovic wrote:
>>
>> Is there any advanced DOM API planned for file upload? For example, how
>> can a script find out how many files is the user about to submit?
>
> I've just added input.files to handle this case.

For the record, this works in Firefox 3.5 already (I believe it also
works in Firefox 3.0), so people can test out this API already.
Feedback would be excellent.

> On Mon, 30 Apr 2007, Ian McKellar wrote:
>> On 4/25/07, David Hyatt <hyatt at apple.com> wrote:
>> > The use case of being able to drop images into a contenteditable
>> > region and have them show up as <img> elements at the appropriate
>> > place and then get automatically uploaded somewhere is a really
>> > compelling one.
>>
>> This is basically what we implemented in Flock. We also supported drag
>> and drop to text areas, though that's a little tricker since it's hard
>> for the user agent to work out how to embed images correctly. At the
>> basic level there's HTML vs BBCode syntax, beyond that different sites
>> filter different sets of tags and attributes in different fields (for
>> example on Flickr img tags are allowed in some fields in your profile
>> but not in others).
>
> I've added dataTransfer.files to the drag-and-drop interface.

This is implemented in recent firefox nightlies. Please test this out
and give feedback!

> I'm not sure how to expose the presence of data during the drag, though.

I think we currently list "application/x-moz-file" in the .types
property. Obviously we'd like to use a better type than that. Could we
simply use "application/file"? Do we need to register the type with
IANA? I expect yes.

Alternatively we could add mimetypes of the actual files (as returned
my File.mediaType), however then it won't be possible to differentiate
a "text/plain" file, from a string. There also more privacy issues
with exposing the mimetypes of the files during "drag" events so I
think i'd like to stay away from that for now.

/ Jonas


More information about the whatwg mailing list