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 JSP and the fly likes Image Upload 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 » JSP
Bookmark "Image Upload" Watch "Image Upload" New topic
Author

Image Upload

Deepa Balasubramanayam
Ranch Hand

Joined: Mar 29, 2001
Posts: 39
Hi,
I am developing a website which does Auto sales. Users who are interested to sell their cars, has to enter their car details and necessary images of the car. Following is my question:
How to allow users to attach their car images to the submission form and how to store them? .
Thanks,
Deepa
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Your form tag must have:

You might want to check the oreilly classes by Jason Hunter, or JSPSmartupload, to upload files to your server. Very easy to use.
some developers store the full path name of the image and others store the image as a BLOB type.
hope it helps..


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
Another good package (And one completely free) is the Jakarta Commons FileUpload


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
I recommend Jakarta.
The oreilly package was never meant to be deployed in a production setting. For example, if two users both upload a picture named "struggle_buggy.jpg", oreilly will overwrite the second file with the first one. Jakarta will let you upload the file directly to memory, or to a temporary file if the size is greater than some programmable limit.
I don't think that the oreilly package is junk. I think Jason Hunter did the Java community a wonderful service by releasing this code. I just think it was written only to show how file uploads work, and never meant to be deployed as a component in an enterprise web application.
Deepa Balasubramanayam
Ranch Hand

Joined: Mar 29, 2001
Posts: 39
Thank you. Please suggest which is best
Storing images as blob type or
storing the path of the image ?.
Thanks,
Deepa
Deepak A
Ranch Hand

Joined: Oct 04, 2001
Posts: 120
Hi Deepa,
Were i in thy place i would have definately gone for something like this.
I would never go in for storing images in the database.Make a seperate column(img_cd) within ur database for every user.So every user has a img_cd associated with him, make another table which has img_cd as primary key and img_description as another column, this column holds ur path where u store ur image.
The trick that i am using runs pretty much on the same lines as our very old and sweet term normalisation in databases.
So u have the path of ur image, just get it and display.
Was that a quickie or a bouncer or were u able to digest that explanation.
Do reply either way,
I'll try to think of an alternate solution in the meantime.


Face Off.
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
I also recommend the Jakarta Commons FileUpload library. From a recent blog entry...
With my new blog, I wanted to give myself the ability to upload new images to my host via the web so that I can use them in my blog entries. Normally I'd use FTP or webdav, but we've got an annoying firewall in the way at work.
As a solution, I decided to implement a simple file upload via a HTML (multipart encoded) form. After a quick google, I came across several, but the one that got my attention was Jakarta Commons FileUpload. All I can say is wow. In just a few lines of code you can extract an uploaded file from the HTTP request and save it to disk. I'm wondering what other goodies are waiting to be discovered!

HTH
Simon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Image Upload
 
Similar Threads
help with methods return types
traffic simulator
WA #2 ..... word association
How to include image in a JSP?
How to use JSP?