Storing pictures

I'm building a PHP inventory website in which the customer is going to have upwards of 10,000 items.  The user would like to save 3 or 4 pictures with each item.

How should I store these pictures?  One folder with all uniquely named pics?  One folder per item and each folder contains the pics?  Better solutions?
Sheldon LivingstonConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Store the pictures in the file system.  Store the names (URL paths) of the pictures in the database where you store other information about the pictures.  The exact file/directory structure does not matter, and with only thousands of image files, there will not be any particular performance issues when your web site needs to serve up the pictures.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sheldon LivingstonConsultantAuthor Commented:
Thanks Ray... the concern was if he actually does get 10,000 items with 3 or 4 pics each we'd be looking at 40,000 potential pics... not an issue (you think)?
Alexandre SimõesManager / Technology SpecialistCommented:
Well, storing them in disk is my preferred approach although storing it in the db makes backups (snapshots) much easier to manage.
If the users are able to manage items and images, just make sure your backup procedure take a snapshot of the DB and files repository at the same instant to make sure the data is consistent.

As off how to logically store them, I used to have an algorithm to split files in folders in order to avoid to have more that 255 files per folder. This "kind of" makes sure that listing items in directories doesn't take more time than expected. I don't have it here now but I can search for it later.

Although there's no enforced limit neither in Windows or Linux (as far as I know), thousands of files in a single directory can make list and search operations slower.
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Sheldon LivingstonConsultantAuthor Commented:
Thank you guys
Ray PaseurCommented:
40,000 pix does not feel like a great many to me.  The only problem with storing pictures in the database is that their inherent "bulk" slows everything related to the database, and inevitably someone will write a query that says SELECT * without a LIMIT clause.  Just wait till you see the EXPLAIN SELECT for that query!  You might want to take a representative picture, make 40,000 copies of it, and put all of them in your server for a performance test.

In any case, best of luck with it, ~Ray
Sheldon LivingstonConsultantAuthor Commented:
Thank you Ray
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.