I know there are many jquery plugins available for file upload.But it just shows how can we added it in the jsp page.But i want to know that how we can deal with the files that are selected using these plugins in the backend.For example am using spring with struts2.So i want to send these files in my action class from my jsp and to store it in the server location.Any body know how can i do it.
1 Answer
userImage is the name of the <file> tag
public class FileUploadAction extends ActionSupport{
private File userImage;
private String userImageContentType;
private String userImageFileName;
private HttpServletRequest servletRequest;
public String execute() {
try {
String filePath = "yourPath";
File fileToCreate = new File(filePath, this.userImageFileName);
FileUtils.copyFile(this.userImage, fileToCreate);
} catch (Exception e) {
e.printStackTrace();
addActionError(e.getMessage());
return INPUT;
}
return SUCCESS;
}
}
From this tutorial
This tutorial explains multiple file upload usinf List
1 Comment
Kamalam
am extending crudActionSupport.Can i use the above method in my action class