Re: Pear/Net_FTP help

From: Date: Thu, 20 May 2004 22:03:09 +0000
Subject: Re: Pear/Net_FTP help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-186634@lists.php.net to get a copy of this message
Hi Chris, Please send your message to pear-general@lists.php.net, you are more likely to get a response there. "Chris" <php@cditty.com> wrote in message news:6.0.3.0.2.20040520153947.01e30818@redhotsweeps.com... > Hi all. Hopefully someone here can show me what I am doing wrong. I am > trying to write a small script to ftp into a server and retrieve a > listing. I am using the Pear module Net_FTP for this. I am able to > connect to the server, but I cannot get a directory listing to work. Here > is my code. > > // PEAR::Net_FTP > require_once 'Net/FTP.php'; > > // Configuration section > $ftp[hostname] = "localhost"; > $ftp[user] = "username"; > $ftp[password] = "password"; > > // Create a new ftp class > $ftp = new Net_FTP(); > > // Time to connect to the ftp server > $ftp->setHostname($ftp[hostname]); > $ftp->setPort(21); > $ftp->connect(); > $ftp->setUsername($ftp[user]); > $ftp->setPassword($ftp[password]); > if(!$ftp->login()){ > echo "Unable to connect to the $ftp[hostname] server. Please > verify your settings and try again.<br>"; > } > $ftp->pwd(); > > // Lets see what we can see. > $ftpLS = $ftp->ls(null, NET_FTP_DIRS_ONLY); > > echo "<pre>"; > print_r($ftpLS); > echo "<pre>"; > $ftp->disconnect(); > > I get a error message back saying it could not retrieve current directory. > > Can anyone offer any help? Example code would be appreciated. Thanks > > Chris

« previous php.general (#186634) next »