You are here: Re: ftp_nlist "425 Can't open data connectoin" « All PHP « IT news, forums, messages
Re: ftp_nlist "425 Can't open data connectoin"

Posted by blackpuppy on 08/28/06 06:23

At last it's solved. It's because of SELinux settings.

I am using GNOME. Go to System --> Administration --> Security Level
and Filewall. Click SELinux tab. Expand "HTTPD Service", and check
"Allow HTTPD scripts and modules to connect to the network". Then
expand "Other", and check "httpd_enable_ftp_server". Finally click OK
button to close the "Security Level Configuration" dialog.

After the above changes, the php web page will work.

Thanks!

blackpuppy wrote:
> Thanks, Patrick!
>
> It works! ftp_pasv($connect, true) will turns on passive mode so that
> the ftp client will initiate the data connection and this will work
> around the firewall. Then I enable FTP in the firewall and the script
> can work without turning on the passive mode.
>
> There is a further problem when I put the above script in a web page as
> shown below.
>
> <HTML>
>
> <HEAD>
>
> <TITLE>
>
> Getting a directory listing with FTP
>
> </TITLE>
>
> </HEAD>
>
>
>
> <BODY>
>
> <CENTER>
>
> <H1>Getting a directory listing with FTP</H1>
>
> Here's what's in the remote directory:
>
> <BR>
>
> <BR>
>
> <?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";
> }
> ?>
> </CENTER>
>
> <BODY>
>
> </HTML>
>
> Then I access it from Firefox with URL
> http://localhost/SpringIntoPHP5/ch09/phpftp.php. The display is:
> ---------------------------------------------------------
> Here's what's in the remote directory:
>
> Couldn't connect to myftpserver.
> ---------------------------------------------------------
>
> So it fails at ftp_connect($ftp_server) call. Does the PHP FTP
> function work differently when running from a web page? Is there
> anything related with Firefox? BTW, other examples from this book work
> just fine when viewing from Firefox. Or is it because the script is
> running under the account apache and this account does not have enough
> privilege?
>
> Thanks again!
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация