PHP: Can't get a directory listing using FTP?

LearningJunkie

New member
I'm working through an example in a great PHP teaching book called "Spring Into PHP 5."

The goal is to connect to an FTP server and get a listing of the directory code22 on that server. The code is as follows:

$connect = ftp_connect("ftp.ispname.com");
$result = ftp_login($connect, "username", "password");

$a = ftp_nlist($connect, "code22");

foreach($a as $value) {
echo $value, "<BR>";
}

This code, however, runs but does not return any listings. Are "ftp.ispname.com" and "code22" things that I need to create, or are they things that already exist on the web?

I'm running a Mac with MAMP as my server.

Thank you for answering my newbie question!
 
ftp.ispname.com is a fake address for the example purpose.

It could have said ftp.example.com too.

You would need to create an FTP account in your MAMP server settings and make that your address.
 
Back
Top