What is the best way to handle images?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply

What is the best way to handle images in your opinion?

Store them in the database.
3
38%
Store them with an unique name in a folder on the server.
5
63%
 
Total votes: 8

Genteel Beaux
Forum Commoner
Posts: 28
Joined: Wed Nov 13, 2002 4:07 pm
Location: Alabama

What is the best way to handle images?

Post 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.
User avatar
Elmseeker
Forum Contributor
Posts: 132
Joined: Sun Dec 22, 2002 5:48 am
Location: Worcester, MA

Post 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...
Genteel Beaux
Forum Commoner
Posts: 28
Joined: Wed Nov 13, 2002 4:07 pm
Location: Alabama

Post 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.
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post 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.
Beans
Forum Commoner
Posts: 49
Joined: Mon Dec 23, 2002 3:06 am
Location: Manila, Philippines
Contact:

Post by Beans »

Why not just store the image URL into the DB? Hehe.. gives you best of both worlds.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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.
Post Reply