File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Uploading Images using Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Uploading Images using Struts" Watch "Uploading Images using Struts" New topic

Uploading Images using Struts

Vikram Virk

Joined: Mar 13, 2006
Posts: 8
I want to know how can I restrict the size and type of file being uploaded using Struts.My application is uploading any type of file.I am saving file to a folder in my harddisk.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Look at the upload example in the struts-examples.war file that comes with the Struts download. It gives an example of how to give an error message if the uploaded file exceeds a certain size. As for restricting what types of files to upload, you could simply look at the file extension and accept or reject a file based on that.

Consultant, Sima Solutions
I agree. Here's the link:
subject: Uploading Images using Struts
jQuery in Action, 3rd edition