wood burning stoves 2.0*
The moose likes Struts and the fly likes Struts upload not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts upload not working" Watch "Struts upload not working" New topic
Author

Struts upload not working

Sree Jag
Ranch Hand

Joined: Oct 14, 2003
Posts: 77
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


Sree Jag<br />SCJP 1.4
hrt prasad
Greenhorn

Joined: Sep 02, 2004
Posts: 4
Try putting method="post" in the form tag.

also - "onclic" for image - Is this a spelling mistake?
Sree Jag
Ranch Hand

Joined: Oct 14, 2003
Posts: 77
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

Joined: Oct 14, 2003
Posts: 77
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
 
 
subject: Struts upload not working