php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48285 ftp_nlist fails
Submitted: 2009-05-14 18:35 UTC Modified: 2009-05-14 21:48 UTC
From: me at andreylis dot ru Assigned:
Status: Not a bug Package: FTP related
PHP Version: 5.2.9 OS: debian
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:
MUST BE VALID
Solve the problem:
22 - 21 = ?
Subscribe to this entry?

 
 [2009-05-14 18:35 UTC] me at andreylis dot ru
Description:
------------
hello

ftp_nlist($connect, $directory)

if $directory contains '+' nothing is returned

Reproduce code:
---------------
function ftpList ($hostname, $username, $password, $directory) {
	$connect  = ftp_connect($hostname);
	$autorize = ftp_login($connect, $username, $password);
	$buff = ftp_nlist($connect, $directory);
	foreach ($buff as $element) {
		$size = ftp_size($connect, $element);
		if ($size < 0) { $type = "dir"; } else { $type = "file"; }
		$return[] = array("name" => $element, "size" => $size, "type" => $type); 
	}
	sort($return);
	return $return;
	ftp_close($connect);
}

Expected result:
----------------
array with ftp names and sizes sorted by alphabet

Actual result:
--------------
nothing

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-14 21:17 UTC] carsten_sttgt at gmx dot de
> if $directory contains '+' nothing is returned

Maybe a problem with the FTP server? This script is working for me with PHP5.2.9/Windows/BSD:
<?php
$ftp_server    = 'ftp.perl.org';
$ftp_user_name = 'anonymous';
$ftp_user_pass = 'guest';
$directory     = '/pub/gnu/commonc++'; // contains '+'

$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
$contents = ftp_nlist($conn_id, $directory);
ftp_close($conn_id);

var_dump($contents);
?>

Regards,
Carsten
 [2009-05-14 21:48 UTC] jani@php.net
There are several things that might be going wrong:

a) buggy ftp server
b) firewall settings (see bug #47110)

The above test script works fine for me as long as I replace the server 
with 'ftp.funet.fi' and directory with '/pub/gnu/gnu/commonc++'
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Jul 06 00:05:46 2022 UTC