wood burning stoves 2.0*
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Upload file Struts 2 + Ajax" Watch "Upload file Struts 2 + Ajax" New topic

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:


<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')"/>



function submitDatos(actionFrm){

document.getElementById("save").style.visibility = "visible";
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

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.

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