The examples in this article describe the use of ftp_chdir and Ftp_cdup functions in PHP. Share to everyone for your reference. The specific usage is as follows:
Ftp_chdir () function
If successful, returns TRUE, otherwise returns false, and if the switch directory fails, PHP also issues a warning.
Syntax: Ftp_chdir (ftp_connection,directory)
Parameters |
Describe |
Ftp_connection |
Required, specify the FTP connection to use, and the identifier for the FTP connection. |
Directory |
Required, specify the directory to which you want to switch.
|
Copy Code code as follows:
Set up the underlying connection
$conn _id=ftp_connect ($ftp _server);
Log on to the FTP server with the specified username password
$login _result=ftp_login ($conn _id, $ftp _user_name, $ftp _user_pass);
Check if the connection was successful
if (! $conn _id) | | (! $login _result))
{
Die ("FTP connection has failed!");
}
echo "Current directory:", Ftp_pwd ($conn _id), "n";
To perform a toggle directory operation
if (@ftp_chdir ($conn _id, "Somedir"))
{
echo "Current directory are now:", Ftp_pwd ($conn _id), "n";
}
Else
{
echo "couldn ' t change Directoryn";
}
Ftp_cdup ($dir); To perform a toggle directory operation
/*
The Ftp_cdup () function changes the current directory to the parent directory on the FTP server.
If successful, returns TRUE. otherwise returns false.
Grammar
Ftp_cdup (ftp_connection)
I hope this article will help you with your PHP program design.