Filenames with spaces in them

From: Date: Fri, 14 Dec 2001 20:05:32 +0000
Subject: Filenames with spaces in them
Groups: php.general 
Request: Send a blank email to php-general+get-77771@lists.php.net to get a copy of this message
Consider this code for traversing through a directory structure: <?php function traverse($path='.') { $path = realpath($path); $dir = opendir($path); echo "\nDirectory : $path\n"; echo str_pad('',76,'-')."\n"; while (false !== ($file = readdir($dir))) {
    if (is_dir($file) && $file != '.' && $file != '..') {
      traverse("$path/$file");
      echo $file;
    }
} closedir($dir); } echo '<pre>'; traverse(); echo '</pre>'; ?> Now when I run it in a directory that has a file with spaces in it's name.. for examples purposes, the file willbe called "file name with spaces". Directory : /home/mike/php/test ---------------------------------------------------------------------------- Warning: stat failed for file name with spaces (errno=2 - No such file or directory) in /home/mike/php/dirdump.php on line 10 Any ideas why this error happens and what I can do to get around it? Mike

« previous php.general (#77771) next »