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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: me at andreylis dot ru
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 06:01:30 2024 UTC