Image files vs. image blobs

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
chris12295
Forum Contributor
Posts: 113
Joined: Sun Jun 09, 2002 10:28 pm
Location: USA
Contact:

Image files vs. image blobs

Post by chris12295 »

which is more efficient, creating a directory for each user and saving images as files in the directory, or saving the images as blobs in a database? It seems that blobs would be much better organized but maybe not so efficient?
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

I would go with files and folders.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

yup... that's what they're for. Filesystems are for files. Databases are for data. :wink:
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Make sure you properly sniff the images and make sure they're actually what they claim to be.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Store metadata in the database if you need to. Images belong in files yeah. You can get large amounts of data out of files a lot quicker than databases but there are many other reasons why files are better.
Xoligy
Forum Commoner
Posts: 53
Joined: Sun Mar 04, 2007 5:35 am

Post by Xoligy »

ole wrote:Store metadata in the database if you need to. Images belong in files yeah. You can get large amounts of data out of files a lot quicker than databases but there are many other reasons why files are better.
Yup, that's what I do. You can then use "deny from all" in a.htaccess to prevent direct access to the files (PHP will still be able to access them). Storing images in the database can really slow things down, not to mention it's harder to backup etc.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Keep them outside of the document root if you want to prevent direct access. It is generally known to be a more reliable way to protect your files.
Post Reply