Page 1 of 1

Best Strategy for Image Uploads

Posted: Mon Sep 13, 2010 6:14 am
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

Re: Best Strategy for Image Uploads

Posted: Mon Sep 13, 2010 6:27 am
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.