This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Upload an Image file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Upload an Image file" Watch "Upload an Image file" New topic

Upload an Image file

varkala prabhakar
Ranch Hand

Joined: Sep 08, 2001
Posts: 54
Hai all,
i have a problem with uploading the image file.
In my html file i use the tag like
<input type=file name=image> and in my servlet getParameter("image") , i get the path of the file and this works fine for my local system, but i want the file to be uploaded even from client machines.
can any one help me how to modify my html and servlet program so that i can store the image in my java web server.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

1. Are you specifying in your HTML form that the enctype="multipart/form-data"
2. Are you specifying that the method="post"
3. out of the box, HTTPRequest doesn't understand a multipart/form-data submission, so are you using a home-made solution to parse the request appropriately, or do you have a package like com.oreilly.servlet?
priti doshi

Joined: Aug 03, 2001
Posts: 6
You can use the jspsmartupload package. It has the code for uploading images.
Malhar Barai
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
go on with mike's solution if using servlets...check on all things...
com.oreily..did help me...try it...

Malhar Barai
SOA & Java Book
varkala prabhakar
Ranch Hand

Joined: Sep 08, 2001
Posts: 54
than u mike,priti and malhar,
My Uploading got worked out with oreilly package. thanx for suggesting me the package.
Don't get me started about those stupid light bulbs.
subject: Upload an Image file
Similar Threads
Mixing content
can HTML page be displayed using servlet in app-serv communication
Giving a URL for File
Can I read my local image file inside the Servlet
Trying to display java.awt.Image in a JSP page.