Its to do with the browser security manager, in i.e. anyway,
you can't script the File field in any fashion with regards to file
location, size etc..

You'll need to write an applet and do some io to do the checking if you need
to validate client
side.

In Netscape their are ways round this with special javascript functions that
have access to disk
client side. Devedge.com is where I was reading this. However in a public
domain the lowest common
denominator is what your looking for.

The problem with the applet is if you have more fields than just a file
field to submit then your
going to want to have the applet make the actual http post. Once it
validates your file field it can
call a javascript function which can then pass the rest of the form element
values into the applet for
posting to your server. You won't be able to do the reverse, again due to
the security manager.

-----Original Message-----
From: Joe Germuska [mailto:[EMAIL PROTECTED]
Sent: 24 January 2005 15:22
To: Nathan Coast; Struts Users Mailing List
Subject: Re: max file size - validator - javascript


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            
[EMAIL PROTECTED]  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to