You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nathan Coast <na...@codeczar.com> on 2005/01/24 08:01:37 UTC

max file size - validator - javascript

Hi,

Does the validator support max file size for an uploaded file?  I have 
found various threads covering how to specify the max file size and how 
to check if it is exceeded but this all seems to be server-side and 
outside of the validator mechanism
e.g.
http://www.mail-archive.com/user@struts.apache.org/msg12942.html

I'm not even sure if it is possible to find the size of a file upload 
within javascript.  Obviously if it isn't possible from javascript, it 
can't be implemented in the validator (not in the client at least).

cheers
Nathan
-- 
Nathan Coast
Managing Director
Codeczar Ltd
mob : (852) 9049 5581
tel : (852) 2834 8733
fax : (852) 2834 8755
web : http://www.codeczar.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: max file size - validator - javascript

Posted by Joe Germuska <Jo...@Germuska.com>.
At 3:01 PM +0800 1/24/05, Nathan Coast wrote:
>Hi,
>
>Does the validator support max file size for an uploaded file?  I 
>have found various threads covering how to specify the max file size 
>and how to check if it is exceeded but this all seems to be 
>server-side and outside of the validator mechanism
>e.g.
>http://www.mail-archive.com/user@struts.apache.org/msg12942.html
>
>I'm not even sure if it is possible to find the size of a file 
>upload within javascript.  Obviously if it isn't possible from 
>javascript, it can't be implemented in the validator (not in the 
>client at least).

I don't believe there is any standard client-side mechanism for 
enforcing something like this.   Here's an unauthoritative reference:
http://www.cs.tut.fi/~jkorpela/forms/file.html#restr

Interestingly, the original File upload RFC (1867) suggested that the 
meaning of "maxlength" in a "file" type input element be used as a 
hint to the maximum acceptable upload size.  However, the HTML 4 spec 
clearly says that in this context, "maxlength" refers to the length 
of the file path (a silly thing to enforce, since the client-side 
file path should be immaterial to the server.)

Furthermore, I would think there would be scoping/timing problems, as 
before the form is submitted, the browser wouldn't want to fool with 
the file, because it might be lag-inducing, and once the form is 
submitted, there's no longer a chance for JavaScript to execute.

Seems like a shortcoming of the spec to not permit page authors to 
specify this in the tag, but it's probably because they didn't want 
to clutter the <input> element spec with too many modal details. 
(Although there is the rarely-used "accept" element which is supposed 
to accept an enumeration of permitted MIME types for the upload.)

Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: max file size - validator - javascript

Posted by Jim Barrows <ji...@gmail.com>.
On Mon, 24 Jan 2005 15:01:37 +0800, Nathan Coast <na...@codeczar.com> wrote:
> Hi,
> 
> Does the validator support max file size for an uploaded file?  I have
> found various threads covering how to specify the max file size and how
> to check if it is exceeded but this all seems to be server-side and
> outside of the validator mechanism
> e.g.
> http://www.mail-archive.com/user@struts.apache.org/msg12942.html

The validator mechanism is server side, or client side, so it will work.

> 
> I'm not even sure if it is possible to find the size of a file upload
> within javascript.  Obviously if it isn't possible from javascript, it
> can't be implemented in the validator (not in the client at least).
> 
> cheers
> Nathan
> --
> Nathan Coast
> Managing Director
> Codeczar Ltd
> mob : (852) 9049 5581
> tel : (852) 2834 8733
> fax : (852) 2834 8755
> web : http://www.codeczar.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org