The ftp_chdir () function changes the current directory on the ftp server.
If yes, true is returned. Otherwise, false is returned. If the directory fails to be switched, the php tutorial will also issue a warning.
Syntax
Ftp_chdir (ftp_connection, directory) parameter description
Ftp_connection is required. Specifies the ftp connection to be used (the ftp connection identifier ).
Directory is required. Specifies the directory to switch.
*/
// Set the basic connection
$ Conn_id = ftp_connect ($ ftp_server );
// Log on to the ftp server with the specified username and password
$ Login_result = ftp_login ($ conn_id, $ ftp_user_name, $ ftp_user_pass );
// Check whether the connection is successful
If ((! $ Conn_id) | (! $ Login_result ))
{
Die ("ftp connection has failed! ");
}
Echo "current directory:", ftp_pwd ($ conn_id), "n ";
// Switch the Directory
If (@ ftp_chdir ($ conn_id, "somedir "))
{
Echo "current directory is now:", ftp_pwd ($ conn_id), "n ";
}
Else
{
Echo "couldn't change directoryn ";
}
Ftp_cdup ($ dir); // you can call this operation to switch directories.
/*
The ftp_cdup () function changes the current directory to the parent directory on the ftp server.
If yes, true is returned. Otherwise, false is returned.
Syntax
Ftp_cdup (ftp_connection)
*/
?>