Current Location: Home> Function Categories> ftp_chdir

ftp_chdir

Change the current directory on the FTP server.
Name:ftp_chdir
Category:Uncategorized
Programming Language:php
One-line Description:Change the current directory on the FTP server.

Definition and usage

ftp_chdir() function changes the current directory on the FTP server.

If successful, return true. Otherwise, return false. If the directory switch fails, PHP will also issue a warning.

Example

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

//Output the current directory
echo "Dir: " . ftp_pwd ( $conn ) ;
echo "<br />" ;

//Switch to images directory
ftp_chdir ( $conn , "images" ) ;
echo "Dir: " . ftp_pwd ( $conn ) ;

ftp_close ( $ftp_server ) ;
?>

Output:

 Dir: /
Dir: /images

grammar

 ftp_chdir ( ftp_connection , directory )
parameter describe
ftp_connection Required. Specifies the FTP connection to be used (the identifier of the FTP connection).
Directory Required. Specify the directory to switch to.
Similar Functions
Popular Articles