Jump to content

How to store images in mysql via php


FantomOptik
 Share

Recommended Posts

I have a database setup with the following fields: ID, StoneName, StoneSize, StoneType, Thumbnail.Essentially, this is an inventory database that the user can view, edit, delete the records. This all works wonderfully. The user would like to have the form display the records and a thumbnail of the product. I cannot seem to figure out what the best method of housing the images and how to display them. I have read that it is not wise to store the images in the database. I should have the path to the thumbnail in the Thumbnail field.I want the thumbnail to be a hyperlink to the full size image (I would like it to have a lightbox effect). I currently have the inventory in a static html page with the lightbox js.I have all of the full size images in a /images directory. What do I put in the mysql 'Thumbnail' field to make this work?Any help or examples would be greatly appreciated.P.S. - for now, I will manually upload the pics to the directory, but eventually I will want to give the user the ability to upload their own pic when they are adding new inventory items.Thanks!

Link to comment
Share on other sites

Thanks for the fast reply. So if my image is in /images/image.jpg, I would put image.jpg in the sql field, then have php actually handle the path (adding the actual http://www.website.com/images/ path)?

Store only the base filename, that way if your files move you don't have to update the database records. Have PHP add on the rest of the path, the database only needs the filename.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...