Pear/Net_FTP help

From: Date: Thu, 20 May 2004 20:45:47 +0000
Subject: Pear/Net_FTP help
Groups: php.general 
Request: Send a blank email to php-general+get-186624@lists.php.net to get a copy of this message
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 (#186624) next »