Struts2: file upload not working : PLzzzzz help,
April 9, 2009 at 6:43 PM
I'm trying to do upload a file using struts2 file tag. Followed all the mentioned as given in http://struts.apache.org/2.0.11/docs/file-upload-interceptor.html. but still am not able to retreive the file contents in my action class. Below is the code snippet which i added. ApplicationResources.properties struts.messages.error.uploading=a general error that occurs when the file could not be uploaded struts.messages.error.file.too.large=occurs when the uploaded file is too large struts.messages.error.content.type.not.allowed=occurs when the uploaded file does not match the expected content types specified
MyAction.java import java.io.File; //The below properties with getter and setter methods defined private File subUploadFile; // The actual file private String uploadContentType; // The content type of the file private String uploadFileName; // The uploaded file name and path
public String uploadFile() throws Exception { System.out.println("Inside uploadFile() ....."); System.out.println("File : " + getSubUploadFile()); System.out.println("File Name : " + getUploadFileName()); System.out.println("Content type : " + getUploadContentType()); return SUCCESS; }