File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Validating an image upload via Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validating an image upload via "Validator-form.xml"" Watch "Validating an image upload via "Validator-form.xml"" New topic
Author

Validating an image upload via "Validator-form.xml"

Akshat Joshi
Greenhorn

Joined: Jun 28, 2010
Posts: 4
Hi,

I tried searching the internet but couldn't get anything regarding this topic.

I have a <html:file> in my jsp which uploads an image to the server. I want to validate this using the validator-rules.xml but can't figure out how to go about it.

Can someone please help me on how to define the rules in my validator-form.xml (this contains my validation for all the forms), so that I can validate the file to be uploaded.

Thanks in advance.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8900
    
    8

What are you trying to validate? That a file name was entered? That a file exists?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Akshat Joshi
Greenhorn

Joined: Jun 28, 2010
Posts: 4
Trying to validate whether the file is within the size limit and also if it is an image file.

I know I can do these validations in action level manually but I want to validate using the struts provided validation framework. Possible?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8900
    
    8

Not that I know of. I believe file upload is delegated to the Apache Commons FileUpload package, so file size limitations are enforced by it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validating an image upload via "Validator-form.xml"