Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Uploading Multiple Files Using html:file

 
Vijay RamaRaju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All.,

I am working with Struts and i ran into a problem while trying to upload multiple files using struts tags.

<logic:iterate ....>
<html:file property="formFile" indexed="true"/>
<html:button property="Upload" indexed="true"/>

</logic:iterate>


and in formBean

private FormFile formFile=null;

public FormFile getFormFile(){
return this.formFile;
}

public void setFormFile(FormFile formFile){
this.formFile = formFile;
}


for example the generated response has 10 browse buttons for uploading files., when i upload some file in the 10th "Browse" then its accepting a for all the remaining browse(textbox) buttons., nothing is getting uploaded into server,Infact its taking null values. The main problem is that i am unable to find an accurate mapping in as formBean property for the jsp defined UI control.


Help me out.

Thanks
Vijay
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a dozen or so pages that used indexed properties, but each time I have to look through the Struts documentation or use the previous code as an example. Do you really want to use an indexed property here?

If so I would expect your bean to contain an array or List of FormFile objects and that you would have methods like this:


- Brent
 
Deepa More
Ranch Hand
Posts: 68
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Brent,
Is there a need to user indexed property if I have to use form files array?
There will be multiple files uploaded that has same property name in struts form and unknown number of files to be uploaded. Is there any examples available to refer the same situation?

Thanks
Deepa
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic