Disk approach
Create an img
parent directory, with a subdirectory for each product's images.
./img
./img/eggs
./img/eggs/eggs1.jpg
./img/eggs/eggs2.jpg
./img/spam
./img/spam/myspamimage.jpg
./img/cheese
...
This way you'll have all your images stored in a single tree hierarchy that makes good sense. If you're going to have a very large amount if images (say, more than 100,000) you can group the images according to creation date:
./img
./img/2010-08/eggs
./img/2010-08/eggs/eggs1.jpg
./img/2010-08/eggs/eggs2.jpg
./img/2010-09/spam
./img/2010-09/spam/myspamimage.jpg
./img/2010-09/cheese
...
This way, you will be able to move some months (probably the older ones) to an archive and keep the month subdirectory as a link to another disk.
Database approach
If you need to keep a lot of metadata on each image (e.g., username, SKU, description, copyright etc) you can store the images using arbitrary image names (probably img/img0000001.jpg
, /img/img0000002.jpg
, ...) and keep a database record that maps a product to its image. This is very useful for searching all the images with a certain characteristics (user, creation date, etc.) associated with them.