Save image and retrieve it to velocity template
I'm using spring 2.5 + velocity for my application. I have requirement to upload an image and retrieve it.
I need to just save the url in the DB ,but not the actual image.
how to achieve this requirement, so that it will work in production environment as well.
I did in the following way, but i'm unable to retrieve the image.
I uploaded the image and save it to a local folder in local disk.(D:/..) in velocity template i ponited the img src to the picture location(i.e: D:/..) And, i'm able to see the picture using firebug, but picture is not displayed the 开发者_StackOverflow中文版browser.
Please help me in finding the efficient way to implement this functionality.
Thanks
Assuming all your pictures are located in the same folder which is web accessible (you can access it via http://
, like http://example.com/images/
), you should only save image filename into the database, like image.jpg
.
After that you can build image url for display by appending image folder url (usually stored in config file) and filename from db.
So at the end it would be something like:
<img src="${imgRootUrl}${filename}">
精彩评论