Images in databases

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jdavis
Forum Newbie
Posts: 1
Joined: Fri Nov 02, 2007 4:54 am

Images in databases

Post by Jdavis »

Hello, I fear im going to ask the simplist question ever posted, however it hav been haunting me for ages now.

I have a database which people can add their details to, but now i want to be able to upload an image to the database and have it recalled when a search is performed.

Regards,
James
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Did you try to search first?
Anyway, I'll save you the effort:

1. Images go to the file system in the usual way (upload them normally like any other file).
2. Store in the database the path to the image.
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

There is the method of storing the images as BLOB data but I've been advised no end this isn't a good way to treat your MySQL server.
User avatar
louie35
Forum Contributor
Posts: 144
Joined: Fri Jan 26, 2007 8:40 am
Location: Dublin
Contact:

Post by louie35 »

I found Oren's option to be the best.
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Post by markusn00b »

Agreed, saving the uploaded images in a new directory and then saving the path to the image in the DB is the best way about it :)
Post Reply