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
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
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.
Joined: Mar 29, 2001
Thank you. Please suggest which is best Storing images as blob type or storing the path of the image ?. Thanks, Deepa
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.
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!