|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32708 ftp_nlist and ftp_rawlist not working in ver 5
Submitted: 2005-04-14 22:02 UTC Modified: 2005-05-03 02:28 UTC
From: predecess at hotmail dot com Assigned:
Status: Not a bug Package: FTP related
PHP Version: 5.0.3 OS: Red Hat Enterprise Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
15 + 18 = ?
Subscribe to this entry?

 [2005-04-14 22:02 UTC] predecess at hotmail dot com
ftp_nlist does not work anymore, nor does ftp_rawlist.
Code that used ftp_nlist worked fine on PHP 4.3.9 and simply copying the code to a server running PHP 5.0.3 breaks it.  

The /tmp directory's mode/permissions is set to 777

Reproduce code:
// Get FTP file list
$ftpconn = ftp_connect('');
if ($ftpconn) {
	if (ftp_login($ftpconn, 'username', 'password')) {
		$path = '/this/same/task/works/fine/with/a/url/wrapper/';
		$files = ftp_nlist($ftpconn, $path);
		foreach ($files AS $filelist) {
			echo $filelist.'<br>';

Expected result:

Actual result:
Warning: Invalid argument supplied for foreach() in /documentroot_path/ftpBUG.php on line 9


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-16 01:03 UTC]
This works fine for me (tm):

// Get FTP file list
$ftpconn = ftp_connect('');
if ($ftpconn) {
 if (ftp_login($ftpconn, 'username', 'password')) {
   $path = '/pub/Linux/';
   $files = ftp_nlist($ftpconn, $path);
   foreach ($files AS $filelist) {
     echo $filelist, "\n";

(I won't quote here what Sara said about this bug report on IRC.. :)

 [2005-04-19 19:45 UTC] predecess at hotmail dot com
I tried the code you provided and it failed for me with the same error.  I'll try again when we upgrade to 5.0.4 or 5.0.5 and see if it works then.
 [2005-05-03 02:28 UTC] predecess at hotmail dot com
We found out that what was causing this was the fact that the server that we upgraded also had a firewall installed on it.  

To fix this problem, call ftp_pasv($ftpconn, true); after calling ftp_login($ftpconn,'username','password')
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon May 23 03:05:45 2022 UTC