This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Need help in looping 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 » Java » Java in General
Reply locked New topic

Need help in looping

pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 300

Below is my code for putting multiple file to the sever.

But it overwrite the name and the content of the files with last one.

Please tell me where i am wrong

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

You define your variable "theFile" outside the loop where you assign a value to it, so it will overwrite each time the loop loops.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
David Newton

Joined: Sep 29, 2008
Posts: 12617

This question was already answered multiple times in your original posting.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 37939
David Newton wrote:This question was already answered multiple times in your original posting.
I looked for a duplicate posting earlier, but missed it. Thank you David for pointing this out: closing thread.
I agree. Here's the link:
subject: Need help in looping
Similar Threads
ENCTYPE='multipart/form-data and request.getParameter
how to display images on JSP in struts2
multiple file upload in Strut2
Struts 2 FileUpload working locally but not on server
How to rename and upload a file?