Page 1 of 1

What is the best way to handle images?

Posted: Mon Dec 23, 2002 4:21 pm
by Genteel Beaux
I am working on a pretty large site. Each member of my site will have the ability to add a picture of themselves. I am currently at a crossroads. I am wondering it is better to stores images in the database or store them in a directory on the server and call them based on an unique name. Using images with databases is new to me, so excuse me if it seem elementary.

Posted: Mon Dec 23, 2002 4:40 pm
by Elmseeker
I'm not quite sure about this, I suppose it would depend on your preferences...personally I would keep them in a directory and just put the URL pointing to them in the DB but this is largely due to the fact that I don't know enough about MySQL yet to know how to put an image into it hehe...as for giving each one a unique name that should be an easy matter so again I would go this route, I am assuming of course that a user can only upload a pic if they are registered and logged in so just have it name the file either the same as the user name.jpg or .gif or whatever or name it by the users ID...either way would work pretty well I'd think...

Posted: Mon Dec 23, 2002 5:11 pm
by Genteel Beaux
Well, I am kind of like you. I just managed to put an image into a mysql database, but I still don't know how to read an image pulled from a mysql database on a php page.

Posted: Mon Dec 23, 2002 5:33 pm
by mydimension
while ive never stored images in a DB, i am familiar with the process of getting them in and out. in light of that i still favor storing images in a directory cause it is less of a hit to you DB and the amount of code required is much smaller.

Posted: Mon Dec 23, 2002 6:16 pm
by Beans
Why not just store the image URL into the DB? Hehe.. gives you best of both worlds.

Posted: Mon Dec 23, 2002 8:45 pm
by hob_goblin
Beans wrote:Why not just store the image URL into the DB? Hehe.. gives you best of both worlds.
This is generally how it would be done anyways. Storing them in a folder takes up a great deal less processing power.