my dog learned polymorphism*
The moose likes Struts and the fly likes Upload file Struts 2 + Ajax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Upload file Struts 2 + Ajax" Watch "Upload file Struts 2 + Ajax" New topic
Author

Upload file Struts 2 + Ajax

Gerenne Vives
Ranch Hand

Joined: Feb 05, 2005
Posts: 60
Hi all,

I'm try to do upload file with struts2+ ajax, my problem is that the input file never arrive to the Action.

This is my code example:

JSP:

<s:form id="uploadDoc" theme="simple" namespace="/files" action="doUpload" method="post" enctype="multipart/form-data">

<s:file name="file" cssClass="field_medium"/>

<input type="button" value="Upload" onclick="javascript:submitDatos('form#uploadDoc')"/>

</s:form>

js:

function submitDatos(actionFrm){

document.getElementById("save").style.visibility = "visible";
$.ajax({
type: 'POST',
enctype: 'multipart/form-data',
url: $(actionFrm).attr('action'),
data: $(actionFrm).serialize(),
success: function() {
document.getElementById("save").style.visibility = "hidden";
}
})
return false;

}


Thanks in advance.
Gerenne Vives
Ranch Hand

Joined: Feb 05, 2005
Posts: 60
Hi all,

This problem is soved now, finally I used jquery library "ajaxfileupload", and now it's work.

Thanks for all!!
Ramzi Oueslati
Greenhorn

Joined: Nov 08, 2012
Posts: 1
Hi Gerenne Vives

It seems you managed to do something I have been trying to do for 2 days. Could you help me please ?
If you could provide a few details like action class and javascript code I would be very grateful.

Regards.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Upload file Struts 2 + Ajax
 
Similar Threads
File Transfer in Apache Web Server
Uploading Image file from client to the server
acessing data of the textarea within the form of multipart type
About form submission
mutipart/form-data