PHP | ftp_pwd() function Last Updated : 02 Dec, 2022 Comments Improve Suggest changes Like Article Like Report The ftp_pwd() function is an inbuilt function in PHP which returns the current directory name of the specified FTP connection. This function was introduced in PHP 4. Syntax: string ftp_pwd( $ftp_conn ) Parameter: This function accepts single parameter $ftp_conn which is used to specify the used FTP connection. Return Value: It returns the current directory name on success or False on failure. NOTE: This function is available on PHP 4.0.0 and newer versions. Example 1: php <?php // PHP program to connect and login // to the FTP server // Initialize ftp server address $ftp_server = "ftp.example.com"; $ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server"); // Initialize ftp username $ftp_username = "johndoe"; // Initialize ftp password $ftp_userpass="john#96"; $login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass); // Change the current directory to php ftp_chdir($ftp_conn, "php"); // Print current directory name (/php) echo ftp_pwd($ftp_conn); // Close connection ftp_close($ftp_conn); ?> Output: /php Note: This code cannot be run in few of the online IDE as this do not give permission for ftp connection. If it supports then use a working ftp server url, username, password and moreover then it display the directory name. Example 2: php <?php // PHP program to connect and login // to the FTP server // Initialize ftp server address $ftp_server = "ftp.example.com"; // Set the basic connection $conn_id = ftp_connect($ftp_server); // Initialize ftp username $ftp_user_name="johndoe"; // Initialize ftp password $ftp_user_pass="john#96"; // Login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // Change directory to public_html ftp_chdir($conn_id, 'public_html'); // Print current directory /public_html echo ftp_pwd($conn_id); // Close the connection ftp_close($conn_id); ?> Output: /public_html Reference: http://php.net/manual/en/function.ftp-pwd.php Comment More infoAdvertise with us Next Article PHP | ftp_pwd() function G gekcho Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP | ftp_put() function The ftp_put() function is an inbuilt function in PHP which is used to upload files to FTP server.Syntax:  ftp_put( $ftp_connection, $remote_file_path, $local_file_path, $mode, $start_position ); Parameter: This function accepts five parameters as mentioned above and described below:  $ftp_connecti 3 min read PHP | ftp_raw() function The ftp_raw() function is an inbuilt function in PHP which is used to send a raw command to the Remote server i.e. FTP Server. Syntax: ftp_raw( $ftp_connection, $command ) Parameters: This function accepts two parameters as mentioned above and described below:  $ftp_connection: It is required para 2 min read PHP | ftp_size() function The ftp_size() function is an inbuilt function in PHP which is used to get the size of a given file on FTP server.Syntax:  ftp_size( $ftp_connection, $file_name ); Parameter: This function accepts two parameters as mentioned above and described below:  $ftp_connection: It is required parameter. It 3 min read PHP | ftp_rawlist() function The ftp_rawlist() function is an inbuilt function in PHP which returns a list of files with information like permissions, last modified the files from a specified directory on Remote server i.e. FTP Server. Syntax:  ftp_rawlist( $ftp_connection, $directory, $recursive ) Parameters: This function a 2 min read PHP | ftell( ) Function The ftell() function in PHP is an inbuilt function which is used to return the current position in an open file. The file is sent as a parameter to the ftell() function and it returns the current file pointer position on success, or FALSE on failure.Syntax:  ftell( $file ) Parameters Used: The ftel 2 min read PHP | fstat( ) Function The fstat() function in PHP is an inbuilt function which is used to return information about an open file. The file name is sent as a parameter to the fstat() function and it returns an array with the following elements : Numeric Associative Description 0 dev Device number 1 ino inode number* 2 mode 3 min read PHP | ftp_exec() function The ftp_exec() function is an inbuilt function in PHP that is used to execute a command on the FTP server. Syntax: ftp_exec( $ftp_connection, $command ) Parameters: This function accepts two parameters as mentioned above and described below:  $ftp_connection: It is required parameter. It specifies 2 min read PHP | ftp_chdir() function The ftp_chdir() function is an inbuilt function in PHP which is used to change the current directory on the FTP server. Syntax: ftp_chdir( $ftp_connection, $directory ) Parameter: This function accepts two parameters as mentioned above and described below:  $ftp_connection: It is required paramete 2 min read PHP | ftp_nlist() function 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. Syntax: ftp_nlist( $ftp_connection, $directory ); Parameters: This function accepts two parameters as mentioned above and described below 3 min read Like