I have a site, and I am going to put up an image upload script for my members. When saving images to the server would it be better to make separate directories such as: site.com/images/ user's unique id / photoid.extension or just site.com/images/userid_photoid.ext both would create unique filenames so I wouldn't have a problem there, but wondering which is faster and better?
The userid_photoid.ext option would be one less folder write and could potentially be faster. I think both are fine as they are unique file names. I prefer the folder approach, as it's easier to navigate the file structure and delete the files later. You can always go back and test each approach out with timers if you think one will outperform the other.
Depending on the server configuration, i've known some operating systems/languages to complain when having to read directories full of huge quantities of files.
Hi, If you make it in the userid_photoid format, it will be hell to delete one user (for uploading pr0n maybe ) . If you make it as folders, you can just delete the corresponding folder. Thats just my 2c. Thomas
yes, never have a GIGANTIC folder of images. Seek time would be huge.... but if they are seperated per user, and even seperated furhter beyond that - it would be best.
mysql 5 is quite good a storing Large binary objects, and seek times are great for large databases (mine is well over 10gb now for one particular image upload site) heck thats what databases were designed for at first i was sceptical that mysql cant handle so much data and was storing in folders, but mysql 5 proved to be very very good and capable, also using php5s PDO extension is handy for easily and efficiently reading and writing large amounts of data