wood burning stoves 2.0*
The moose likes Struts and the fly likes Struts multiple file upload array index problem 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 "Struts multiple file upload array index problem" Watch "Struts multiple file upload array index problem" New topic
Author

Struts multiple file upload array index problem

Sunil Sunny
Ranch Hand

Joined: Oct 18, 2011
Posts: 41
i have to upload multiple files(3) with a title field , it is not compulsory that user will upload all 3 files . any user may upload 1 or may be 2 or may be all 3.

but when i am checking in my Struts execute function it always show the length of "songtitle[]" array 3 but length of "Gana[]" field not 3 and length of gana field depend on value selected if i select 1 file for uploading length is 1 ifI select 2 files for uploading it is 2 when no file is selected it shows null . So i am struggling to how to retreive correct title and file value. Here is my code.

<s:form action="addsongs" enctype="multipart/form-data" theme="simple" method="post">

<table><tr><td>Enter The Song Title:</td><td><s:textfield name="songtitle" value=""/>
</td></tr><tr><td>First File:</td><td>


<s:file name="gana" value=""/></td></tr>

<tr><td>Enter The Song Title:</td><td><s:textfield name="songtitle" value=""/>
</td></tr>
<tr><td>Second File</td>


<td>

<s:file name="gana" value=""/></td></tr>
<tr><td>Enter The Song Title:</td><td><s:textfield name="songtitle" value=""/>
</td></tr><tr><td>Third File</td>

<td>
<s:file name="gana" value=""/></td></tr><tr><td colspan="2" align="center">

<s:submit type="image" src="../images/submit.gif"/></td></tr><tr><td></table>
</s:form>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts multiple file upload array index problem
 
Similar Threads
unable to do validation for select in struts2
Help in Debugging
multiple file upload in Strut2
Could not find a Content-Type for upload in struts2
problem in printing the values