Ftp_chdir and Ftp_cdup function usage _php techniques in PHP

Source: Internet
Author: User
Tags ftp connection parent directory

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.

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.