W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2009

Re: Proposal for sending multiple files via XMLHttpRequest.send()

From: Anne van Kesteren <annevk@opera.com>
Date: Tue, 20 Oct 2009 13:31:27 +0200
To: "Darin Fisher" <darin@chromium.org>
Cc: public-webapps@w3.org
Message-ID: <op.u13jmpoa64w2qv@annevk-t60>
On Tue, 20 Oct 2009 10:56:47 +0200, Darin Fisher <darin@chromium.org>  
wrote:
> On Tue, Oct 20, 2009 at 1:37 AM, Anne van Kesteren <annevk@opera.com>  
> wrote:
>> I think for a lot of authors the easiest would be easiest if it was in  
>> the form of multipart/form-data as then they do not have to do anything  
>> special to get the data on the server.
>
> That does address the primary use case, but do you really think that we
> should rule out the use case of custom encodings?
>
> (At least for Gecko and WebKit, it is really trivial to support the more
> free-form interface since the underlying network layers speak in terms  
> of a list of strings and file references.)

I do not want to rule anything out, but a request I repeatedly hear is  
duplicating <form> functionality with XMLHttpRequest. Support for  
multipart/form-data furthermore is extremely widespread and resembles  
quite closely what is desired so it seems good to use it.

If eventually we get native support for octet-arrays and all we can at  
that point add the ability to XMLHttpRequest so you can send anything you  
want.


> If we do go the more specific route, then it could look like this:
>
> var data = new FormData;
> data.appendText("name1", "value");
> data.appendFile("name2", fileData);
> xhr.send(data);
>
> The UA could populate the filename attribute of the Content-Disposition
> header based on the given fileRef.  Same goes for the Content-Type  
> header.
>
> Hmm... this may indeed be a good way to go since I don't think the  
> proposed
> FileData (
> http://dev.w3.org/2006/webapi/FileUpload/publish/FileAPI.html#FileData-if)
> interface includes a name attribute.

This looks reasonable to me.


I suppose we also want support passing File[Data] and FileList directly as  
I believe WebKit might have already added. Do you happen to know the  
implementation details?


(I'm planning to wait with defining this until at least after TPAC. I  
expect more discussion to happen there and I also want to keep focus on  
the CSSOM before switching tasks again. It would be good to have most of  
the details before than though.)


-- 
Anne van Kesteren
http://annevankesteren.nl/
Received on Tuesday, 20 October 2009 11:32:04 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:34 GMT