• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Akshat Joshi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9318
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you trying to validate? That a file name was entered? That a file exists?
 
Akshat Joshi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9318
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic