Best Strategy for Image Uploads

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
ReportsNerd
Forum Newbie
Posts: 4
Joined: Thu Jul 29, 2010 7:13 am

Best Strategy for Image Uploads

Post by ReportsNerd »

Hello,
I want to be able to allow people to upload their profile pictures to my site, but I am uncertain about the best way to do this. I basically want to have a thumbnail and larger profile picture, but control how big they can be in both file size and dimensions. I’m thinking about storing each photo in a blob field in MySQL, but I’m not sure what the best strategy will be regarding maintenance, long-term impact, etc.

Suggestions appreciated.

Thanks in advance.
ReportsNerd
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Best Strategy for Image Uploads

Post by requinix »

Until you start thinking about issues like server clouds and database replication, store files as actual files - not in the database. However in the database you will need to keep track of file location and image type.
When they upload the image, check the size. If too large then you can shrink it to the maximum dimensions allowed (or warn the user and ask for them to upload something else). I suggest you then create a second, thumbnail-sized image, rather than try to create the thumbnail on-the-fly.
Post Reply