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.
- PHP | Ds\Set first() Function
- D3.js | d3.lab() Function
- p5.js | value() Function
- PHP | Ds\Set contains() Function
- D3.js | d3.map.set() Function
- PHP | Ds\Set add() Function
- PHP | Ds\Map xor() Function
- D3.js | d3.rgb() Function
- p5.js | int() function
- PHP | Ds\Set last() Function
- PHP | min( ) Function
- PHP | max( ) Function
- PHP | pos() 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.