Just read your other thread, and I was wondering why you wanted to limit the folder to 1000 items....it's all clear now🙂
But one problem with the "every event gets it's own folder"
FTP clients will still have to connect up to the containing folder; once you get 1,000 events, you have 1,000 folders, ie, 1,000 items in the ftp root. You're back to square one, aren't you?
if 1,000 folders aren't enough (that is enough for 1,000,000 items according to the 1,000 items per) then you can just add one more layer of complexity to the $i function by adding in a while for $d (for directory 😉 )and have $d create 0-999 directories, each one of which is creating $i subdirectories with its own while statement for $i. Then you have 1,000 X 1,000 folders each containing 1,000 items--that allows for a billion items that ftp and dreamweaver users should be able to deal with. Change your rand() statement to pull up 2 random numbers, one for the containing directory, one for the subdirectory, and you'll be fine. What are the odds with 1,000,000 directory combinations that you'll hit 1,000 items? If you really want to check against it, create a function on your administration page that looks for subdirectories with over 1,000 items, moves a chunk of it to another file with space, and updates the database with the new dir info
As far as name collisions, that should be checked for in the db regardless, not by parsing filenames in a folder. Quick on a db (especially if you index the column), thrashing to the disk by checking filenames in the directory.
Users can still find whatever events they want by knowing the eventid --you just have to use the eventid as the primary key (which you should be doing anyway!) and using that as your call to the DB--any way you want the user to be able to access it is up to you. Don't overestimate the ability of your users, however; How the heck are they supposed to know what the eventid is for their specific event? They'd have to query the db at some point to get that info. You might as well serve it up to them in the first place. If they do know the eventid, it's just as easy to let them pass it in the url with a %dir%/?eventid=999 type of entry.