Hi,
first of all you should use ENCTYPE="multipart/form-data" METHOD="post" in
your FORM. If you have the following form:
<FORM action="http://server.com/cgi/handle"
enctype="multipart/form-data"
method="post">
<P>
What is your name? <INPUT type="text" name="submit-name"><BR>
What files are you sending? <INPUT type="file" name="files"><BR>
<INPUT type="submit" value="Send"> <INPUT type="reset">
</FORM>
and you type Larry and choose file1.txt your user agent will send back to
the server the followings:
Content-Type: multipart/form-data; boundary=AaB03x
--AaB03x
Content-Disposition: form-data; name="submit-name"
Larry
--AaB03x
Content-Disposition: form-data; name="files"; filename="file1.txt"
Content-Type: text/plain
... contents of file1.txt ...
--AaB03x--
So you have to:
-use getHeader("Content-type") with somme processing to retrieve the
boundary(AaB03x in our case)
-use getInputStream() to obtain the stream containing de request data.
-retrieve the content of the file from the stream using boundary value.
Maybe you don't have to work so hard if your server has already somme
classes for doing all this stuff.
Bye
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
Sushant Kumar
Sent: Monday, August 21, 2000 4:46 PM
To: [EMAIL PROTECTED]
Subject: File upload..
Hi all..
I am trying to upload a file to my server using Form. I am setting one of
the the input's type as File. But, on the servlet side I couldn't find any
method to read the request's data as file..
does anyone has any idea about how to do this?? I am using web-server
provided with jswdk1.0.1.
Regards,
Sushant
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html