UploadAction.java package test.web; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import com.opensymphony.xwork2.ActionSupport; @SuppressWarnings("serial") public class UploadAction extends ActionSupport { private String title; private File upload; private String uploadContentType; private String uploadFileName; public File getUpload() { return upload; } public void setUpload(File upload) { this.upload = upload; } public String getUploadContentType() { return uploadContentType; } public void setUploadContentType(String uploadContentType) { this.uploadContentType = uploadContentType; } public String getUploadFileName() { return uploadFileName; } public void setUploadFileName(String uploadFileName) { this.uploadFileName = uploadFileName; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String execute() throws Exception { FileOutputStream fos = new FileOutputStream("D://temp//" + getUploadFileName()); FileInputStream fis = new FileInputStream(getUpload()); byte[] buffer = new byte[1024]; int len = 0; while ((len = fis.read(buffer)) > 0) { fos.write(buffer, 0, len); } fos.flush(); fos.close(); return SUCCESS; } } upload.html <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Upload Test</title> </head> <body> <form action="upload.action" method="post" enctype="multipart/form-data"> <input type="file" name="upload"><br/> <input type="text" name="title"><br> <input type="text" name="uploadFileName"><br/> <input type="text" name="uploadContentType"><br/> <input type="submit"> </form> </body> </html>