Search w3schools.com:

SHARE THIS PAGE

PHP ftp_nlist() Function


PHP FTP Reference Complete PHP FTP Reference

Definition and Usage

The ftp_nlist() function lists the files in a specified directory on the FTP server.

This function returns an array of file names on success or FALSE on failure.

Syntax

ftp_nlist(ftp_connection,dir)

Parameter Description
ftp_connection Required. Specifies the FTP connection to use
dir Required. Specifies the directory to check. Use "." to get the current directory


Tips and Notes

Note: This function does not work with IIS (Internet Information Server). It returns nothing.


Example

<?php
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");

print_r(ftp_nlist($conn,"images"));

ftp_close($conn);
?>

The output of the code above could be:

array(3)
{
[0]=> "flower.gif"
[1]=> "car.gif"
[2]=> "house.gif"
}


PHP FTP Reference Complete PHP FTP Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]