Oh, that makes a lot more sense now thanks. I didn't even think of the path in that conditional being the problem.
Printable View
Oh, that makes a lot more sense now thanks. I didn't even think of the path in that conditional being the problem.
Yes, that's right. I missed it last night.
All functions like is_dir(), etc., operate based on the current directory so once you are inside a folder (like images) you need to operate based on that-- add the path.
This usually becomes an issue with recursive functions, so I'm used to putting it there: you open a directory and run through the files then run through inside it's directories, and of course you'll need to start with the relative path.
But here is was just one folder, so it is easy to miss that-- except that you were in the first place operating in a different directory. readdir() is always just the filename, not path info.