wood burning stoves 2.0*
The moose likes Struts and the fly likes Struts2: How to do file upload validation programatically ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2: How to do file upload validation programatically ?" Watch "Struts2: How to do file upload validation programatically ?" New topic
Author

Struts2: How to do file upload validation programatically ?

Sakthi Priya
Greenhorn

Joined: Apr 02, 2009
Posts: 26
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Apr 02, 2009
Posts: 26
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Struts2: How to do file upload validation programatically ?
 
Similar Threads
upload file from windows for Unix server
maxFileSize validation for RequestProcessor
How to upload a file using a servlet?
refresh onload
FileUpload using Struts