Hi all,
Can anyone shed any light on this really simple problem please?
I need to read a list of files in a directory on a server. I am using PHP to do something like this...
$counter=0;
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$filetype=(pathinfo($file));
I then decide using an if(($filetype[extension]=="txt")||($filetype... to choose what to do with the file.
The problem is this. the readdir($handle) function does not return filenames if the filename has a blank space within its name. So it will read "myfile.txt" okay, but will skip "my file.txt" the problem seems to be the space in the filename because if I manually remove the spaces (from my test files) the function works perfectly well.
Oh and by the way, unfortunately I cannot guarantee file-name consistency in here, so I have to assume there will be names with spaces!
Any suggestions would be really appreciated. thanks in advance, JohnB.