Can I use HTTP to upload a file to a web server?

Yasar Qureshi

Yes, you can upload a file using HTTP, but you need to write a servlet or a CGI script or some other server-side executable to receive the incoming file.

To send the file, create an HTML form for the client to use. Your form field should have input type "file" to let the user browse and select the file to be uploaded. Also, your form tag should have the "enctype=multipart/form-data" attribute in order to successfully pass file's contents to web server using HTTP. For example, the HTML form tag might look like this:

<FORM method="POST" action="someservlet" enctype="multipart/form-data">
form fields
<INPUT type="file" name="file1">
You can get further information regarding processing HTML forms from: http://www.w3.org/TR/WD-html40-970708/interact/forms.html

Use O'Reilly's servlet package to write the servlet which receives the file sent by the form. You can get O'Reilly's servlet package at http://www.servlets.com/resources/com.oreilly.servlet/