Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

upload files 1

Status
Not open for further replies.

yama

Programmer
Jun 28, 2001
69
SG
Hi,
I want to save some form details and a certain picture file to the server and store the picture pathname to the database on the server using JSP codes. For example, I have this upload.jsp that contain this html code --> <input type=file name=upload size=20>.
I will be able to choose any file from my client computer, then i will have a save button, when i press it, all the form details on upload.jsp will be send to save.jsp. How do i save the picture file that i have choosen at the form to the server? anyone has any idea???
thanks!!!
 
Here a link for using the O'Reilly Java Package: . This is an example from Jason Hunter's excellent Servlet Programming book. This package makes uploading a file extremely easy. Back in the day we had to do this all by hand. You should feel lucky.

BTW, the correct HTML to send an file upload to a Servlet or JSP is:
Code:
<FORM ACTION=&quot;upload.jsp&quot; ENCTYPE=&quot;multipart/form-data&quot; METHOD=POST>
<INPUT TYPE=FILE NAME=file>
<INPUT TYPE=SUBMIT>
</FORM>
The important parts are the ACTION tag (obviously), the ENCTYPE needs to be &quot;multipart/form-data&quot; and the <INPUT TYPE=FILE> tag will allow the user to actually select the file for upload.
Wushutwist
 
hmm..but is there any way to write the codes using JSP?
 
I implement the UploadTest.java in mi webserver but when i run it, the webbrowser says, the page cannot be found, any reason?
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top