Net_FTP and spaces in foldernames Bug?

From: Date: Fri, 28 Nov 2003 12:20:32 +0000
Subject: Net_FTP and spaces in foldernames Bug?
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-9201@lists.php.net to get a copy of this message
Hi. I have been experiencing some difficulties with Net_FTP and spaces in foldernames. first I begin with creating a test folder on the account I am trying to access. I call the folder "my files". Here is the code: <?php require_once('Net/FTP.php'); $ftp = new Net_Ftp(); $ftp->setHostname("my.ftp.server"); $ftp->setUsername('username'); $ftp->setPassword('pass'); if(PEAR::isError($error = @$ftp->connect())) die($error->getMessage()); if(PEAR::isError($error = @$ftp->login())) die($error->getMessage()); $basedir = $ftp->pwd(); if(PEAR::isError($ftp->cd('my files'))) die($error->getMessage()); $curdir = $ftp->pwd(); echo "Current dir: ". $curdir; echo '<br />'; $counter = 0; foreach($ftp->ls() as $file) { echo $file['name'].'<br />'; $counter++; } echo 'Total number of files: '.$counter ?> With this code I receive a list of 0 files even though the directory "my files" contains a dozen files. Putting var_dump($ftp->ls($dir = $curdir, $rawlist = NET_FTP_RAWLIST)); into the code before the foreach results in receiving array(0) { } as expected. However putting var_dump($ftp->ls($dir = false, $rawlist = NET_FTP_RAWLIST)); into the code before the foreach results in receiving the correct rawlist. As you can see this is odd behaviour and inconsistent. Folders not including spaces work fine in both trials. Problem seems to be connected to the spaces. I have also tried to escape the space with $ftp->cd('my\ files'); and $ftp->cd("my\ files"); without luck. Am I doing anything wrong here ? Has anyone had the same problem ? Can this be addressed somehow ? Regards, Birgir Stefansson

« previous php.pear.general (#9201) next »