ds111 Posted July 17, 2009 Share Posted July 17, 2009 Hello, I am building a website and I expect around 10,000 users. Throughout the website, I allow users to upload images (up to 50 images/user) for various purposes. The problem I am facing is how to store the image? Should I save the encoding of the image in MySQL, or should I have a separate directory for each user and store the path in MySQL? Which would be the most efficient, and why? Thank you very much for your help. Quote Link to comment https://forums.phpfreaks.com/topic/166363-where-to-store-images/ Share on other sites More sharing options...
ldougherty Posted July 17, 2009 Share Posted July 17, 2009 You do not want to store the images themselves in the database, this causes the database to become absurdly huge and slow. Just store the images locally on the server and reference the paths in your database. Quote Link to comment https://forums.phpfreaks.com/topic/166363-where-to-store-images/#findComment-877290 Share on other sites More sharing options...
ds111 Posted July 17, 2009 Author Share Posted July 17, 2009 Thanks. Should I create 10,000 separate directories (one per user) or one per 100 users or ... Assuming 10,000 users and 50 images each. What is better: may small directories or large one with a lot of files? Quote Link to comment https://forums.phpfreaks.com/topic/166363-where-to-store-images/#findComment-877319 Share on other sites More sharing options...
ldougherty Posted July 17, 2009 Share Posted July 17, 2009 I created a gallery myself and the structure I used was to have an albums directory where you have a directory for each album created. The only downfall is that no two albums can have the same name, so you would have the same thing to consider where no two users could have the same user name. How you store them ultimately is up to you in what you feel would meet your needs the best. The one other thing to keep in mind is that with Linux you do have a max links value for the OS meaning you can only have so many files in one directory. The number is something ridiculous though so likely not a problem you'd run into. Quote Link to comment https://forums.phpfreaks.com/topic/166363-where-to-store-images/#findComment-877336 Share on other sites More sharing options...
ds111 Posted July 17, 2009 Author Share Posted July 17, 2009 Thanks for your advice. I will create one directory per user. I hope that Linux "ridiculous" number of directories is more than 10,000. Quote Link to comment https://forums.phpfreaks.com/topic/166363-where-to-store-images/#findComment-877345 Share on other sites More sharing options...
Daniel0 Posted July 17, 2009 Share Posted July 17, 2009 I believe it's around 32000 sub directories on ext3. What you can do is that for e.g. the user "daniel" you could do: /var/uploads/d/da/daniel You could of course have even more levels if you want to. Quote Link to comment https://forums.phpfreaks.com/topic/166363-where-to-store-images/#findComment-877362 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.