how to write uploadphoto in the insert update delete using
struts? write code struts and jsp jdbc

Answer Posted / k.v.s.ravindrareddy

****************In jsp*********************

<form name="fileupload" enctype="multipart/form-data"
method="post"
action="/photos/fileuploadresult">
<tr>
<td >Photo 1</td>
<td ><input type="file" name="uploads[0]" /></td>
</tr>
<tr>
<td >Photo 2</td>
<td ><input type="file" name="uploads[1]" /></td>
</tr>
<tr>
<td>
<input type='submit' name="submit" value="Submit">
</td>
<tr>
</form>
*************** in struts-config.xml*************

<action path="/photos/fileuploadresult"
type="com.uploads.actions.FileUploadAction" name="PhotoUpload"
scope="request" >
<forward name="success" path="/photos/fileuploadresult.jsp" />
</action>


<form-bean name="PhotoUpload"
type="com.uploads.forms.FileUploadForm">
</form-bean>

***************in FileUploadForm.java***************

public class FileUploadForm extends ActionForm {

private List formFiles = new ArrayList();

public List getUploads() { return this.formFiles; }

public void setUploads(int iIndex, FormFile formFile){
this.formFiles.add(formFile);
}

}

***************In execute method of
FileUploadAction.java***************

FileUploadForm uploadForm=(FileUploadForm)form;
List myFiles =(List) uploadForm.getUploads();
for(int i=0;i<myFiles.size();i++){
if(myFiles.get(i)!=null){
FormFile myFile =(FormFile)myFiles.get(i) ;
/*process ur file......*/
}
}

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of struts config xml file?

656


Where can I get a copy of struts?

714


What do you mean by dynaactionform?

719


What is container struts2?

747


Why do the struts tags provide for so little formatting?

754


How to convert struts to spring mvc?

732


What are the contents on web.xml in struts application ?

723


What is actionmapping?

819


Explain how can we upload files in struts2 application?

816


How does one create an action in struts 2?

703


What are the components of struts framework?

780


What is the purpose of dispatcher result type?

737


Explain the complete struts validator framework.

755


What types of validations are available in xml based validation in struts2?

784


Explain struts?

759