Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: Multipart file upload in applet

Reply
Thread Tools

Re: Multipart file upload in applet

 
 
Arne Vajhøj
Guest
Posts: n/a
 
      07-17-2008
Kenneth P. Turvey wrote:
> I'm having some difficulty getting file upload to work. I'm using some
> sample code of questionable utility and I was hoping someone here could
> give me a hand.
>
> The basic problem is that I need to post to a servlet an image and some
> associated metadata. It should look just like it does when it is posted
> by the following web page:
>
> <html>
> <head>
> <title>Image Uploader</title>
> </head>
> <body>
> <form method="POST" enctype="multipart/form-data"
> action="http://www.squeakydolphin.com/ImageUpload/ImageUpload">
> Category<input type="text" name="Category" /><br/>
> UserId<input type="text" name="UserId" /><br/>
> Image<input type="file" name="Image" /><br/>
> <input type="submit" />
> </form>
> </body>
> </html>
>
>
> It is accepted as multipart data on the server end and that works fine.
> I just can't seem to get the client to produce the write output. Is
> there a class library I can use to ease getting this correct?


Use the Apache HttpClient package, classes HttpClient, PostMethod
and MultipartRequestEntity !

Arne
 
Reply With Quote
 
 
 
 
Kevin McMurtrie
Guest
Posts: n/a
 
      07-18-2008
In article <487fd6c5$0$90263$(E-Mail Removed)>,
Arne Vajhøj <(E-Mail Removed)> wrote:

> Kenneth P. Turvey wrote:
> > I'm having some difficulty getting file upload to work. I'm using some
> > sample code of questionable utility and I was hoping someone here could
> > give me a hand.
> >
> > The basic problem is that I need to post to a servlet an image and some
> > associated metadata. It should look just like it does when it is posted
> > by the following web page:
> >
> > <html>
> > <head>
> > <title>Image Uploader</title>
> > </head>
> > <body>
> > <form method="POST" enctype="multipart/form-data"
> > action="http://www.squeakydolphin.com/ImageUpload/ImageUpload">
> > Category<input type="text" name="Category" /><br/>
> > UserId<input type="text" name="UserId" /><br/>
> > Image<input type="file" name="Image" /><br/>
> > <input type="submit" />
> > </form>
> > </body>
> > </html>
> >
> >
> > It is accepted as multipart data on the server end and that works fine.
> > I just can't seem to get the client to produce the write output. Is
> > there a class library I can use to ease getting this correct?

>
> Use the Apache HttpClient package, classes HttpClient, PostMethod
> and MultipartRequestEntity !
>
> Arne


Or build the POST manually and use Sun's Http code. It's not that hard
to stick a file inside a template.

Using Apache libraries in an Applet could really drive up bandwidth
costs for some uses.

--
Goolge is a pro-spamming service. I will not see your reply if you use Google.
 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      07-18-2008
Lew wrote:
> Arne Vajhøj wrote:
>>> Use the Apache HttpClient package, classes HttpClient, PostMethod and
>>> MultipartRequestEntity !

>
> Also,
> <http://commons.apache.org/fileupload/>


That is server side. I am pretty sure that the question
was for client side.

Arne
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      07-18-2008
Kevin McMurtrie wrote:
> In article <487fd6c5$0$90263$(E-Mail Removed)>,
> Arne Vajhøj <(E-Mail Removed)> wrote:
>
>> Kenneth P. Turvey wrote:
>>> I'm having some difficulty getting file upload to work. I'm using some
>>> sample code of questionable utility and I was hoping someone here could
>>> give me a hand.
>>>
>>> The basic problem is that I need to post to a servlet an image and some
>>> associated metadata. It should look just like it does when it is posted
>>> by the following web page:
>>>
>>> <html>
>>> <head>
>>> <title>Image Uploader</title>
>>> </head>
>>> <body>
>>> <form method="POST" enctype="multipart/form-data"
>>> action="http://www.squeakydolphin.com/ImageUpload/ImageUpload">
>>> Category<input type="text" name="Category" /><br/>
>>> UserId<input type="text" name="UserId" /><br/>
>>> Image<input type="file" name="Image" /><br/>
>>> <input type="submit" />
>>> </form>
>>> </body>
>>> </html>
>>>
>>>
>>> It is accepted as multipart data on the server end and that works fine.
>>> I just can't seem to get the client to produce the write output. Is
>>> there a class library I can use to ease getting this correct?

>> Use the Apache HttpClient package, classes HttpClient, PostMethod
>> and MultipartRequestEntity !

>
> Or build the POST manually and use Sun's Http code. It's not that hard
> to stick a file inside a template.
>
> Using Apache libraries in an Applet could really drive up bandwidth
> costs for some uses.


My old version of HttpClient is only 225 KB. That is not much today.

And it can actually be a bit tricky to implement POST multipart
100% correct. It is easy to write something that works with some
forgiving server, but to get it to work with a strict server
requires either some standards reading or some sniffing.

Arne
 
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
HTML File Upload using enctype=multipart/form-data in form? Matt Java 8 05-26-2012 07:40 AM
HTML-like multipart/form-data POST file upload for Net::HTTP(rfc1867) leoboiko Ruby 0 08-06-2008 06:13 PM
MIME Structure Multipart/Mixed with attachment and Multipart/Alternative blaine@worldweb.com Perl Misc 1 04-04-2007 08:23 PM
Reading multipart/form-data From a Servlet (File Upload) PythonAnimal@gmail.com Java 3 11-05-2005 01:41 PM
HTML File Upload using enctype=multipart/form-data in form? Matt HTML 1 10-12-2004 08:17 PM



Advertisments