Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2: How to do file upload validation programatically ?

 
Sakthi Priya
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please let me know how to do the file upload validation programatically instead of interceptors ?

I want to allow file type of xls only, Min size and max size

Thanks,
Sakthi Priya
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you want to do a file upload in Struts 2 and not use the Struts 2 file upload mechanism?

Edit

Oh, I think I misunderstood what you were asking; missed the part about validation.

If the commons-upload/regular file upload validation doesn't work for you why not just validate in a validate() method? The "validation" interceptor is in the stack after file upload, so you can do whatever you need to.
 
Sakthi Priya
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please throw some highlight about validate() method? Do i need to implement any interfaces ?

Right now what i'm doing is, on uploading i'm calling some action mthod. Within that method, using the value of
getUploadContentType() i'm deciding whether to throw back the error or not. Still not sure about restricting minimum and maximum size allowed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic