View Single Post
  #5 (permalink)  
Old 08-01-2007, 05:30 PM
molotov molotov is offline
Novice
Join Date: Jul 2007
Posts: 37
iTrader: (0)
molotov is on a distinguished road
Quote:
Originally Posted by Lee View Post
Best way IMO to store the image is store it in a folder and put path to it in the database, path being "imagefolder/imagename.ext" if you get what i mean? its so much easier and it can be much quicker i believe. (this is how avatars are given to users on forums if you look at the user database, normally in a column called "Avatar" or something on those lines.

Hope it helps.

Lee is probably correct for your scenario. It depends on how many images you want to store, whether or not they will be on the same server, what file system you're using, etc. If you're on shared hosting, just use the file system, but don't put all the images in the same directory, otherwise after a while, things will get ugly.

HelloWorld, the way people store an image is by opening the image file, reading the file contents, and storing that as a BLOB in the database (see file_get_contents(). You need to know what kind of image though the information came from so that you can recreate the image when you need to pull it out of the database, so you'll also probably need to store the mime-type, unless you're restricting it to a single file-type somewhere else in the script (before it's in the database).

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to molotov For This Useful Post:
HelloWorld (08-01-2007)