W3C home > Mailing lists > Public > public-html@w3.org > July 2009

Re: Restricting maximum upload size

From: Ian Hickson <ian@hixie.ch>
Date: Mon, 27 Jul 2009 23:22:42 +0000 (UTC)
To: Alfonso Martínez de Lizarrondo <amla70@gmail.com>, John Drinkwater <john@nextraweb.com>
Cc: HTML WG <public-html@w3.org>
Message-ID: <Pine.LNX.4.62.0907272318100.23663@hixie.dreamhostps.com>
On Sat, 11 Jul 2009, Alfonso Martínez de Lizarrondo wrote:
>
> I would like to propose adding a new attribute to <input type="file">, 
> named (for example) maxsize, it should contain a number, the maximum 
> size in bytes allowed by for each single file to be uploaded to the 
> server. If it's missing, or it isn't a positive integer, it will default 
> to 0, meaning that no file check will be done at the client side.
> 
> That way it's possible to restrict the upload of big files without 
> wasting time trying to send it to the server and get back an error 
> message. It will be possible to do this check with Javascript with the 
> filesize attribute of the File interface 
> (http://dev.w3.org/2006/webapi/FileUpload/publish/FileUpload.html#dfn-filesize), 
> but that requires Javascript to be enabled, and adding custom validation 
> to the form.
> 
> Following on that, then comes the issue of <input type="file" multiple>, 
> instead of adding another attribute to the input element, I think that 
> it might be better to add it to the <form>, defining the total size that 
> can be sent as the body of the POST to the server, if the sum of files 
> and other text data it's over the maximum allowed size the form will 
> fail the validation and won't be submitted.
> 
> This feature will be useful also if full directories upload is ever 
> implemented as suggested in 
> http://lists.whatwg.org/htdig.cgi/help-whatwg.org/2008-June/000134.html 
> and as pointed in the reply, a maximum size of upload will avoid 
> selecting too much data.

On Sat, 11 Jul 2009, John Drinkwater wrote:
> 
> Or the attribute maxsize would apply per file, so the total permitted 
> would be maxsize × quantity of files selected. Would that fit better?

On Sat, 11 Jul 2009, Alfonso Martínez de Lizarrondo wrote:
> 
> The maxsize in the <input> would apply to each file, that's what you 
> describe. But the overall maximum size of the upload might be different, 
> so it needs a way to restrict it.
> 
> The developer might state that each uploaded file must be a maximum of 
> 5Mb, and at the same time he wants to allow to upload up to 20 files at 
> a time, but he knows that the server is configured so it only accepts 
> 20Mb in each POST, so you can upload 4 files of 5Mb each, or 20 files of 
> 1Mb each (and every other possible combination).
> 
> In the <form> the maxsize would be mostly the maximum upload size 
> allowed by the server, and the restriction of maxsize for each 
> individual file would be a preference of the site.
> 
> I think that it covers any combination that way.

I've added this feature request to the list of v2 features for file upload 
controls. I haven't added it to the spec itself; we had this in an earlier 
draft, actually, but removed it (if I'm not mistaken, as part of a 
simplification effort). You will probably be able to do this using the 
File API and script in the meantime, once we introduce that (just detect 
when the selected files have changed, check the height, and call 
setCustomValidity() to say it's too big).

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Monday, 27 July 2009 23:23:19 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:15:48 UTC