Re: Filenames with spaces in them

From: Date: Fri, 14 Dec 2001 20:12:45 +0000
Subject: Re: Filenames with spaces in them
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-77775@lists.php.net to get a copy of this message
Ahh forget it .. I figured it out change to is_dir("$path/$file").. *smack* ignore this altogether mike Mike Eheler wrote:
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 (#77775) next »