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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to