You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by John Ellis <jd...@home.com> on 2000/11/22 17:06:41 UTC

Re: Multipart form handling help

Shanx,

I wrote a little class to help me handle that stuff.  It allows you to iterate
through the files (it can handle multiple file in a form) and read their output
streams, then it gives you a hastable of the other parameters on the form.  Give
it a try and let me know what you think.

John


Shanx wrote:

> Can someone give me a sample of how to handle image uploads?
>
> Here is a detailed description of the problem I am facing. I have a FORM
> with a "input type=file" tag, and when someone submits this form, I read all
> the bytes from the inputStream, convert it into CHAR and display it.
> However, this works ONLY if there is ONLY an image upload field in the form.
> If I add a "input type=text" tag in the form, then this doesnt work and the
> bytes of the image are displayed as junk text.
>
> I guess this is because of the "content type"..in case of the form which has
> only the FILE input element, the content type doesnt matter. However, if the
> TEXT imput element is added, the content type changes to TEXT/HTML and hence
> the bytes from the uploaded image are displayed as junk.
>
> I also tried doing an "IMG SRC" of the image bytes in the submitted page.
> But this doesnt work as well!
>
> I have been investigating the MultiPartRequest.java class, but I cant seem
> to figure out how to preview the uploaded image in a browser -- (write these
> bytes to the browser). There is a patchy solution that I am thinking of
> right now, which basically saves the images to the server in a temp drive
> and then displays it. But comeon, Java should be more powerful than that!
>
> I'd appreciate any ideas/code samples. Thanks!
>
> </Shanx>