PHP ftp_mlsd() Function

❮ PHP FTP Reference

Example

Returns the list of files from the "images" directory:

<?php
// connect and login to FTP server
$ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);

$dir = "/images";
$dirlist = ftp_mlsd($ftp_conn, $dir);

// output directory list
echo($dirlist);

// close connection
ftp_close($ftp_conn);
?>

Definition and Usage

The ftp_mlsd() function returns the list of files in the specified directory.

Syntax

ftp_mlsd(ftp_conn, dir);

Parameter Values

Parameter Description
ftp_conn Required. Specifies the FTP connection to use
dir Required. Specifies the name of the directory to be listed. Use "." to get the current directory


Technical Details

Return Value: An array with file info from the specified directory on success, FALSE on failure
PHP Version: 7.2+

❮ PHP FTP Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.