This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes Upload Multiple Images using formfile in JSP Sturts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Upload Multiple Images using formfile in JSP Sturts" Watch "Upload Multiple Images using formfile in JSP Sturts" New topic
Author

Upload Multiple Images using formfile in JSP Sturts

florencia dwinta
Greenhorn

Joined: Jun 12, 2012
Posts: 2
In Form Class :




In Handler Class:



In JSP Class:



Method writeImageToFile:




for your information, my input form is dynamic base on listQuestion, if listQuestion have three images then in screen will be show three input file and if listQuestion have five images then in screen will be show five input file.

my problem is listQuestion have five images, when i'm submit the form, five images can uploaded on server n database but first image until fifth image is same. (all images is same with lastest image choosed) .
i know my mistake is in the attribute of class form (attribute image) but i'm confused how to make the all images can saved on list or array then when i try upload that image, i'm just iterate the list of image.

could you help me, what should i do?


regards,

Florencia.
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Hi Florencia,
You are right, there is a definite problem with the form. What we are having here is a list of FormFiles and we are just having one place holder for it. What we are doing above is we iterate the same FormFile and hence it takes the last assignment. Either we need to have a array of FormFile's and we need to do index it int the JSP. Have you seen this thread with (supposed to be) working solution


Have Fun with Java
little,little.. little by little makes a lot..
florencia dwinta
Greenhorn

Joined: Jun 12, 2012
Posts: 2
Morning Shankar,

Your link really helped me to fix my program

Thank you....
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

That's good news!!!
Worth closing the resolved threads which would be useful for others while doing a search
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Upload Multiple Images using formfile in JSP Sturts