problem with uploading files in java servlets

  • Thread starter bhagaban behera
  • Start date
B

bhagaban behera

i wanted to upload files using a java servlet and save it in a
directory on the server.



the html form is as given:

<FORM ACTION="/PostMultiServlet"
METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="TEXT" NAME="desc" value="">
<INPUT TYPE="FILE" NAME="filecontents" value="">
<INPUT TYPE="SUBMIT" VALUE="Submit" NAME="Submit">
</FORM>


so in the servlet (inside the doPost method :
reponse.getParameter("filecontents")
.........what does it give? just the file name or the file object itself
?
Then how do i save that file?
plz tell me.
if u have some type of code plz put it up.it will b helpfull.
thanx
 
R

Raymond DeCampo

bhagaban said:
i wanted to upload files using a java servlet and save it in a
directory on the server.



the html form is as given:

<FORM ACTION="/PostMultiServlet"
METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="TEXT" NAME="desc" value="">
<INPUT TYPE="FILE" NAME="filecontents" value="">
<INPUT TYPE="SUBMIT" VALUE="Submit" NAME="Submit">
</FORM>


so in the servlet (inside the doPost method :
reponse.getParameter("filecontents")
........what does it give? just the file name or the file object itself
?
Then how do i save that file?
plz tell me.
if u have some type of code plz put it up.it will b helpfull.

Despite its maturity, the servlet specification still does not support
multipart/form-data encoding for uploading files. So you will have to
use a third party solution, either one provided by your application
server or an add-on like the Apache file upload package.

HTH,
Ray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,079
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top