binary upload of a file with servlet

A

Astrid Wagner

Hi,
I want to write a servlet that uploads a file.
I read some about that the content type has to be multipart/formdata but

I would like to have a little example on this.
Can someone help?
Thanks.
Astrid
 
A

Astrid Wagner

Thanks for the link!
The problem I have is that i do not exactly know how to write a servlet
that serves a source for the file upload. Here my problem:
I have a html page that has a input field "file" that will contain the file
name to upload
and a submit button whose action will have to result in writing the file to a
server side
location and display a page accordingly.
The html page:
<form method='POST' ACTION='http://<machine>:<port>/UploadWebFilePage'
enctype='multipart/form-data'>
<input type='hidden' name='page' value='upload_onlinefile_form'>
<input type='hidden' name='next_page' value='save_onlinefile_info'>
<input type='hidden' name='id' value='10612'>
<input type='hidden' name='target' value='edit_view'>
<h2>Upload file for: TestX Rev. 2.0</h2>
<div>
<input type='hidden' name='view_id' value='7520'>

<b>View:</b> one_pager<br>
<br>
File to upload: <input type='file' name='file' size='50'><br>
<br>
<br>
<input type='submit' name='submit' value='Upload File'>
</div>
</form>

How can the UploadWebFilePage servlet read the data in the given file into
another file and create a response that
is of "text/html" MIME type meaning a regular html page? I do not need a
"Save to disk" window appearing asking me to choose where to store
the file because I will evaluate the destination automatically depending on
some of the above hidden input fields.
Thanks.
Astrid
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top