Hi Guys,
I'm fairly new to
struts, so I'm really struggling!!
I need to do the following:
1) read photos from my
jsp page
2) save the folder into a folder.
Here's the code I have so far, but I'm stuck:
<<<JSP>>>>>
<body>
<html:form action="/FileUpload" type="org.apache.struts.validator.DynaValidatorForm" enctype="multipart/form-data">
<table>
<tr>
<td align="center" colspan="2">
<font size="4">ADD Pictures Here</font>
</tr>
<tr>
<td align="right">
File Name
</td>
<td>
<html:file property="sourceFile"/>
</td>
<td>
<html:submit>Upload File</html:submit>
</td>
</tr>
</table>
<<<struts-config>>>
<form-bean name="FileUploadForm" type="org.apache.struts.validator.DynaValidatorForm">
<!-- Dynamic properties of the FileUpload Form -->
<form-property name="sourceFile" type="org.apache.struts.upload.FormFile" />
</form-bean>
<action path="/FileUpload" type="com.poshWebApp.action.FileUploadProcessAction" name="FileUploadForm" scope="request" validate="false" >
<forward name="success" path="/web/service/uploadsuccess.jsp"/>
</action>
<<<action class>>>
public class FileUploadProcessAction extends Action {
public ActionForward execute(ActionMapping mapping_,
ActionForm form_, HttpServletRequest request_,
HttpServletResponse response_) throws Exception {
String status = null;
System.out.println("#####Action: entering search detail action class...");
DynaValidatorForm form = (DynaValidatorForm) form_;
FormFile sourceFile = (FormFile) form.get("sourceFile");
String contentType = sourceFile.getContentType();
String fileName = sourceFile.getFileName();
int fileSize = sourceFile.getFileSize();
byte[] fileData = sourceFile.getFileData();
///???
1. how can I save into a folder here???
///???
status = "session";
return mapping_.findForward(status);
}
}
PleaSe hELp!!!