tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shanx" <ad...@shanx.com>
Subject Multipart form handling help
Date Wed, 22 Nov 2000 16:43:08 GMT
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>



Mime
View raw message