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.
0

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)?
0
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.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Sheldon LivingstonConsultantAuthor Commented:
Thank you guys
0
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
1
Sheldon LivingstonConsultantAuthor Commented:
Thank you Ray
0
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
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.