W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2008

Re: Proposal for an extension XMLHttpRequest to allow sending files

From: Arthur Barstow <art.barstow@nokia.com>
Date: Mon, 28 Jul 2008 08:05:09 -0400
Message-Id: <58385176-046F-4CF1-A994-5B87F55F129A@nokia.com>
Cc: Web Applications Working Group WG <public-webapps@w3.org>
To: ext Sam Weinig <weinig@apple.com>

Hi Sam,

This seems like a reasonable extension to me.

A colleague asks "Are there any new security concerns by putting this  
inside XHR, or is the assumption that we are not exposing anything new?"

What are your thoughts on that question? I presume "not exposing  
anything new" given this type of functionality is already provided  
(e.g. form submission as mentioned below).

-Regards, Art Barstow

On Jul 17, 2008, at 4:14 PM, ext Sam Weinig wrote:

> We would like to propose standardizing a way of using  
> XMLHttpRequest to send files to the server.  We propose using a  
> similar (and compatible) API to the Blob based API proposed by  
> Google Gears (http://code.google.com/p/gears/wiki/ 
> BlobWebAPIPropsal), but instead of sending Blob objects, the File  
> objects would be sent.  This will allow the common act of uploading  
> files, now relegated to form submissions with an <input  
> type="file">, to have access to ProgressEvents and the ability to  
> abort mid way through.
> As with the Blob API, this is reuses the File and FileList  
> interfaces exposed by Mozilla (see http://developer.mozilla.org/en/ 
> docs/nsIDOMFile and http://developer.mozilla.org/en/docs/ 
> nsIDOMFileList) in a compatible.  We are not proposing a specific  
> way to get the contents of the files, but that would be a natural  
> future extension.  Other potential future extensions would be  
> access to the icon associated with the file.
> Objects implementing the HTMLInputElement interface must also  
> implement the FileHTMLInputElement interface.
> interface FileHTMLInputElement {
>    readonly attribute FileList files;
> };
> The files attribute must return a FileList containing all the files  
> currently selected.  This list is live, and therefore updates if  
> contents of the input element change.
> interface FileList {
>    readonly attribute unsigned long length
>    [IndexGetter] File item(in unsigned long index);
> };
> Each item in the FileList is File, which is a token representation  
> of file on the system.  The fileName attribute returns just the  
> name and not the complete path.  The fileSize attribute returns the  
> size of the file in bytes.
> interface File {
>    readonly attribute DOMString fileName;
>    readonly attribute unsigned long long fileSize;
> };
> Sending a File can be accomplished with an extension to  
> XMLHttpRequest that overrides the existing send() method.
> Objects implementing the XMLHttpRequest interface must also  
> implement the FileXMLHttpRequest interface.
> interface FileXMLHttpRequest {
>    void send(File data);
> };
> -Sam Weinig
Received on Monday, 28 July 2008 12:18:59 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:11 UTC