No, you can’t have a million files in your directory. Precisely, you can – but you should not have.
Asking why?
Today I was asked to transfer one old site to WordPress platform and everything seems so fine – I’ve created the script that sniffs through old system’s database, adds new posts (4000+), fix images URLs (4000+ posts x few images), redirect old URLs. But then, I noticed that some pictures are missing. For real, they’re not missing, but they are invisible on file list (direct link to file works), except first 1998 files.Like every other programmer would do, I’ve searched for ext2/3/4 specifications and gave specific attention to filesystem limits, but haven’t found any small number like 2000 (I see only first 1998 files + . + ..). All numbers was very large and base is always 2 – you cannot multiple 2 with 2 x times and get 1998 or 2000 so I realized that limit is not set by filesystem. Hosting provider told me that the limit is set by FTP recursion (read sth about that on UnixSurgeon) and this variable cannot be changed because site is on shared hosting. Lame.
Is there a solution?
Yes, there is. Changing ftp recursion limit would fix this issue. Files are not deleted, they’re just not visible in file listing – direct link to files works. There must be the way to download and save them (without clicking Save picture as…).
So, what if you can’t change recursion limit?
You can always store your pictures into subdirectories so I have to create PHP script that reallocates these photos. Organize your photos/files on beginning so you won’t have problems like me, you won’t have invisible files.
And the question: What is the maximum number of files that I can hold in my directory?
A: Depends on filesystem, but check the ftp recursion limit first.
Btw, that’s why WordPress’s storing pictures into subdirectories (year/month) is good.