• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts upload not working

 
Sree Jag
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am trying to add File Upload functionality to my webapp using Struts <html:file>

This is my JSP code:

<html:form action="/itemmaintenance.do" enctype="multipart/form-data" onsubmit="self.opener.location.reload(false);self.close();">

<html:file name="itemmaintenanceForm" property="theFile"/>
<html:image property="image" src="/Images/Admin/btnSave.gif" onclic="this.form.submit()"/>

</html:form>

but when i click on the Save image, the form is submitted without any data.

But it submits all the data if i remove the
enctype="multipart/form-data" from the html:form tag, the form is being submitted with all the data.

Can anyone tell me what's the problem?

Thanks in advance,
Seshu
 
hrt prasad
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try putting method="post" in the form tag.

also - "onclic" for image - Is this a spelling mistake?
 
Sree Jag
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi hr, i tried with method="post" too with no luck. btw, onclic is not a typo...javaranch was not allowing me to post message with onclick.


any other ideas?
 
Sree Jag
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i found the problem.

the problem is not with <b>enctype="multipart/form-data"</b>. the problem is with the <b>onsubmit</b> function.

if i remove teh onsubmit function, then the upload file is working.

any ideas how to solve this problem

Seshu
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic