make the ftp examples work.
I am running PHP scripts on a Fedora Core 5 (VMWare virtual machine) on
top of a Windows XP Professional. The PHP version is 5.1.4. The PHP
script is shown below.
#! /usr/bin/php
<?php
$ftp_server = "myftpserver";
$connect = ftp_connect($ftp_server)
or die("Couldn't connect to $ftp_server.");
$result = ftp_login($connect, "myftpuser", "mypassword")
or die("Couldn't log in $ftp_server.");
$a = ftp_nlist($connect, "/");
foreach($a as $value){
echo $value, "\n";
}
?>
I run the above script in a GENOME terminal. It seems it can connect
and log in to the ftp server successfully. But then the ftp_nlist()
call fails. And the server has the following log for this call.
NLST /I do not know what is wrong. But in a terminal I can manually log in
150 Opening data channel for directory list.
425 Can't open data connection.
the ftp server, and the ls or nlist command will give the file list as
expected. So I suspect the problem is at the PHP ftp function.
The PHP manual on FTP functions
(http://www.php.net/manual/en/ref.ftp.php) has the following
explanation.
"No external libraries are needed to build this extension.
In order to use FTP functions with your PHP configuration, you should
add the --enable-ftp option when installing PHP 4 or greater or
--with-ftp when using PHP 3.
This extension has no configuration directives defined in php.ini."
My questions are:
- How could I know what is wrong with the ftp_nlist() call?
- How could I know if the FTP functions are enabled at PHP
installation?
- How to make the FTP functions work?
Thanks a lot!