Advice needed - Storing images
Hello all,
I'm developing e-commerce application, and I have dilema where to store product photographs.
When I started learning struts and servlets/jsp, I stored photographs as BLOB in MySQL database, and hadnt any problems to do it this way.
For administrator purposes, I created admin interface. Administrator was able to insert new products into database, and in that case inserting product photos was implemented using form file, uploading photos directly from his local computer as BLOB object.
On the other hand, this system will probably damage the performance of web appliacation, so the idea I like more at the moment is using hypelinks.
My problem with hypelinks is - where to store photos? Photographs probably have to be stored somewhere on server, but in that case I would have to give some privilegies to administrator of web site and to allow him to access the server, and I dont want to do that.
Am I missing something here?
Thanks in advance,
Djordje
[1024 byte] By [
djordjewa] at [2007-11-27 1:30:45]

# 3
1) You can do. Save the filename and eventually the path.
2) This doesn't matter, it's your design choice. Keep accessibility, usability and portability in mind. You can store it in /WebContent/images (accessible directly by a simple request URI and high portable), or in /WebContent/WEB-INF/images (accessible by "ImageServlet" only and high portable), or even in c:/images (accessible by "ImageServlet" only and less portable) or so.
# 5
Almost all actually :(
Now I have difficulties with the path. Here is the code I use:
...
ServletContext appServletContext = this.getServlet().getServletContext();
String realPath = appServletContext.getRealPath("/images");
FileOutputStream fos = new FileOutputStream(realPath+"\\" + uploadForm.getFile().getFileName());
...
What I get for realPath is
...\build\web\images
and I would like to get
...\web\images
Any thoughts?
Sorry if this have been answered already, but in 100s of threads related to struts upload, I couldnt find the answer.
# 9
Thanks for your response.
I don't think it has anything to do with '/' or '\' though.
My directories structure is following:
Web Pages
- META-INF
- WEB-INF
- images - this is the destination I would like to store my images
- etc, etc
In my NetBeans project I have following folders:
'build', 'conf', 'dist', 'nbproject', 'src', 'test' and 'web',
and after execution of my upload action, images are stored in 'build' folders, which has following structure:
-build
--web
META-INF
WEB-INF
images
etc, etc
Obviously I would like to store them in my 'web' folder, but just cant get there.
I hope this clears the picture about my problem bit more.