FormFile has a "getFileSize" or similar method that you can use to check the size in 
your processing Action (server side). There, you can also determine the file name and 
check the extension (probably that will be good enough for "type" checking).

In addition, this is one area where I think client side validation (JavaScript) is 
useful. You want your users to find out their input was invalid *before* an upload if 
you can help it. Something I have done that works pretty well is to disable the form 
submit with JavaScript until at least the file name extenstion (file type) that the 
user has entered matches a value from a predetermined list (.jpg, .gif, etc.). I don't 
know how to check the file size on the client however, or whether that's even possible 
(because of security reasons).

I have some example code I could post later if you are interested, but it's all pretty 
straightforward.

Erik


-----Original Message-----
From: Bj <[EMAIL PROTECTED]>
Sent: Sep 24, 2004 11:00 AM
To: Struts Users Mailing List <[EMAIL PROTECTED]>
Subject: file upload problem

Hi,

I'm using <html:file ...> tag to upload image files.
Everything works fine but I want to filter the type of file that the 
user may upload. And also limit the file size.

How can I handle this with Struts ?
I didn't manage to do this in simple html code (apparently because most 
of browsers do not respect html specifications)and I suspect that I'll 
need to check in my Action code.
Am I right ?

Thx

Bj


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



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

Reply via email to