Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > binary upload of a file with servlet

Reply
Thread Tools

binary upload of a file with servlet

 
 
Astrid Wagner
Guest
Posts: n/a
 
      08-18-2003
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



 
Reply With Quote
 
 
 
 
Christophe Vanfleteren
Guest
Posts: n/a
 
      08-18-2003
Astrid Wagner wrote:

> 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


You could use http://jakarta.apache.org/commons/fileupload/, it does what
you need.
--
mvg,
Christophe Vanfleteren
 
Reply With Quote
 
 
 
 
Astrid Wagner
Guest
Posts: n/a
 
      08-18-2003
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



Christophe Vanfleteren wrote:

> Astrid Wagner wrote:
>
> > 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

>
> You could use http://jakarta.apache.org/commons/fileupload/, it does what
> you need.
> --
> mvg,
> Christophe Vanfleteren


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading multipart/form-data From a Servlet (File Upload) PythonAnimal@gmail.com Java 3 11-05-2005 01:41 PM
Upload a file without file Upload control - ASP.Net =?Utf-8?B?U2FyYXY=?= ASP .Net 3 08-03-2005 01:09 AM
Doing a form-based FILE-UPLOAD from inside a servlet DiscoStu Java 1 05-20-2004 11:56 PM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM
File upload servlet using MultipartRequest - file not created on the server Paul Smith Java 1 11-17-2003 10:24 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57