The ftp_connect () function creates a new ftp connection.
If the connection succeeds, a connection ID is returned. Otherwise, false is returned.
Syntax
Ftp_connect (host, port, timeout)
*/
$ File = 'public _ html/index. php tutorial '; // define a file
$ Conn_id = ftp_connect ($ ftp_server); // connect to the specified ftp Server
$ Login_result = ftp_login ($ conn_id, $ ftp_user_name, $ ftp_user_pass); // Log On with the specified user name
If (ftp_chmod ($ conn_id, 0644, $ file )! = False) // sets the file mode.
{
Echo "$ file chmoded successfully to 644n"; // output information
}
Else
{
Echo "cocould not chmod $ filen"; // output information if the setting fails
}
Ftp_close ($ conn_id); // close the ftp connection
/*
The ftp_chmod () function sets the permissions for the specified file on the ftp server.
If the operation succeeds, the function returns the new permission. Otherwise, false is returned.
Syntax
Ftp_chmod (ftp_connection, mode, file)
*/
$ Ftp_server = "ftp.example.com"; // defines the ftp server
$ Ftp_user = "foo"; // define the user name
$ Ftp_pass = "bar"; // defines the user's password.
$ Conn_id = ftp_connect ($ ftp_server) or die ("couldn't connect to $ ftp_server"); // connect to the specified ftp Server
If (@ ftp_login ($ conn_id, $ ftp_user, $ ftp_pass) // if logon is successful
{
Echo "connected as $ ftp_user @ $ ftp_servern"; // output the corresponding information
}
Else
{
Echo "couldn't connect as $ ftp_usern"; // output information that cannot be logged on
}
/*
The ftp_login () function is used to log on to the ftp server.
If the call succeeds, true is returned. If the call fails, false is returned and a warning is issued.
Syntax
Ftp_login (ftp_connection, username, password) parameter description
Ftp_connection is required. Specifies the ftp connection to be used (the ftp connection identifier ).
Username is required. Specifies the username used for logon.
Password is required. Specifies the logon password.