Академический Документы
Профессиональный Документы
Культура Документы
ActionSupport; public class FileUploadAction extends ActionSupport implements ServletRequestAware { private File userImage; private String userImageContentType; private String userImageFileName;
String filePath = servletRequest.getRealPath("/"); System.out.println("Server path:" + filePath); File fileToCreate = new File(filePath, this.userImageFileName);
} }
<s:actionerror /> <s:form action="userImage" method="post" enctype="multipart/form-data"> <s:file name="userImage" label="User Image" />
</head> <body> <h2>Struts2 File Upload Example</h2> User Image: <s:property value="userImage"/>
Uploaded Image: