Photo Storage?

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
bharanidharanit
Forum Newbie
Posts: 15
Joined: Sun Jan 03, 2010 9:13 pm

Photo Storage?

Post by bharanidharanit »

Hi,
I am providing users to store their photos in my website. Which is the best one to store and provide security? file system or database?
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Re: Photo Storage?

Post by Charles256 »

I prefer the filesystem route because it just seems weird to store images in a database. That's just my opinion though.
bharanidharanit
Forum Newbie
Posts: 15
Joined: Sun Jan 03, 2010 9:13 pm

Re: Photo Storage?

Post by bharanidharanit »

Charles256 wrote:I prefer the filesystem route because it just seems weird to store images in a database. That's just my opinion though.
Do u have any idea how social networking websites like, facebook, orkut, twitter are saving the images or photos?
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Re: Photo Storage?

Post by Charles256 »

When I was coding a system where users upload stuff I normally do the following structure

/public_html/user_files/user_name/photos/thumb
/public_html/user_files/user_name/photos/full

/public_html/user_files/user_name/video/screen_shot
/public_html/user_files/user_name/video/movie_file

Or something like that. Disable direct access to those folders then use a PHP script to load stuff up from the folders. Hopefully that gives you a direction to start looking in.
User avatar
timWebUK
Forum Contributor
Posts: 239
Joined: Thu Oct 29, 2009 6:48 am
Location: UK

Re: Photo Storage?

Post by timWebUK »

bharanidharanit wrote:
Charles256 wrote:I prefer the filesystem route because it just seems weird to store images in a database. That's just my opinion though.
Do u have any idea how social networking websites like, facebook, orkut, twitter are saving the images or photos?
I know the exact idea:

Haystack
vanguard
Forum Newbie
Posts: 13
Joined: Mon Jan 11, 2010 9:10 am

Re: Photo Storage?

Post by vanguard »

For small-medium use I would recommend saving photos to disk and having a database entry with the full path of the photo as well as any other details stored with it. This is simply because file operations tend to be faster than database operations, and that databases often have lower space quotas on webhosts than quotas for generic disk space.

- Alex
Post Reply