Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts multiple file upload array index problem

 
Sunil Sunny
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic