The ftp_nlist() function is an inbuilt function in PHP which is used to get the list of all the filename and sub-directory in a specific directory on FTP server.
ftp_nlist( $ftp_connection, $directory );
Parameters: This function accepts two parameters as mentioned above and described below:
- $ftp_connection: It is required parameter. It specifies the already existing FTP connection to get the list of all files and sub-directory of a directory in FTP server.
- $directory: It is required parameter of String type. It specifies the directory in remote server i.e. FTP server whose file & sub-directory is to list.
Return Value: It returns array of file names and sub-directory on success and false on failure.
- This function is available for PHP 4.0.0 and newer version.
- The following examples cannot be run on online IDE. So try to run in some PHP hosting server or localhost with proper ftp server name.
- Don’t confused with filename and sub-directory! Many websites assumed sub-directory name also as filename.
Below examples illustrate the ftp_nlist() function in PHP:
Example 2: Connect to ftp server using port number 21 and then list directory content.
- How to get the function name inside a function in PHP ?
- D3.js | d3.min() function
- PHP | Ds\Set xor() Function
- PHP | pi( ) Function
- PHP | pow( ) Function
- PHP | each() Function
- PHP | Ds\Map put() Function
- D3.js | d3.max() function
- PHP | Ds\Map xor() Function
- PHP | pos() Function
- CSS | rgb() Function
- p5.js | box() Function
- PHP | key() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.