File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Uploading an image. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Uploading an image." Watch "Uploading an image." New topic

Uploading an image.

Dennis Lee

Joined: Dec 03, 2001
Posts: 7
Hi all,
I want to upload an image to the web-server automatically because I use applet to get the image from scanner. Originally I wanted to save the image to disk and call javascript from applet to set the "File" attribute and post, but the "File" is read-only and only change when user browse and choose the file. How could I upload the image automatically by post of jsp or by applet?(besides the image, I also have some other hidden parameters in jsp to post together).
Hope you could help me. Thanks.

Joined: Jan 18, 2002
Posts: 1
hi you have to use multipart concept for that you better to check in should have client like this.
and multipat code is avilable for free download in orielly site
<FORM METHOD=post ACTION="SaveFile.jsp" ENCTYPE="multipart/form-data">
<INPUT TYPE=file NAME=image ACCEPT="image/gif">
<INPUT TYPE=submit VALUE="Submit">
<INPUT TYPE=reset VALUE="Reset Form">
removed wholesale quote -MC
[ January 22, 2002: Message edited by: Mike Curwen ]
Dennis Lee

Joined: Dec 03, 2001
Posts: 7
Maybe my question was not so clear just now.
What I want is no need for user to choose file, the jsp or applet could send the image to server automatically.
The jsp you provided should let the user to choose file. That is not my need.
I agree. Here's the link:
subject: Uploading an image.
It's not a secret anymore!