Re: Multipart file upload in applet



Kevin McMurtrie wrote:
In article <487fd6c5$0$90263$14726298@xxxxxxxxxxxxxxx>,
Arne Vajhøj <arne@xxxxxxxxxx> 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
.



Relevant Pages

  • Re: How to test if RemoteDesktop still connected from c# Options
    ... The sample code I gave you is the minimum to establish a connection and interact with a session on the server. ... Now write code to respond to the events you are interested in as well as add features to the form such as the ability to specify server name, display options, redirection options, etc. ... In a couple of hours or so you should be able to have a custom version that has all the features of the regular Remote Desktop Client plus the ability to monitor and respond to disconnects. ...
    (microsoft.public.windows.terminal_services)
  • Re: Query.asp sample problems
    ... I've gone right back to original sample code to eliminate any issues with my ... Catalog is on the local web server indexing ... previously all I've had to change is the Catalog ... > | allow user to select and set the query scope. ...
    (microsoft.public.inetserver.indexserver)
  • RE: Create Form from Async-Callback
    ... the customer will not see the form. ... Besides, from your sample code, the application is waiting for the client ... Its behavior is very like one server and ASP.net team have one ... for the user interaction. ...
    (microsoft.public.dotnet.general)
  • Re: javamail code in servlet works locally, but not when uploaded to host
    ... there must be some kind of permissions issues on web servers that ... server from which they claim to be. ... // build a string from an XML document ... // Add the message part to a multipart ...
    (comp.lang.java.programmer)
  • Re: Newbie question
    ... > I need some help building a portal for the Sharepoint Server. ... > that, in sharepoint speak, these are called Web Parts. ... Can someone point to sample code and procedure for publishing this ...
    (microsoft.public.sharepoint.portalserver)