Usage of the ftp_chdir () ftp_cdup () function in php

Source: Internet
Author: User
Tags ftp connection

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)
*/
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.