Adjust file permissions.
<?php // connect and login to FTP server $ftp_server = “ftp.example.com”; $ftp_conn = ftp_connect($ftp_server) or die(“Could not connect to $ftp_server”); $login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass); $file = “php/test.txt”; // Try to set read and write for owner and read for everybody else if (ftp_chmod($ftp_conn, 0644, $file) !== false) { echo “Successfully chmoded $file to 644.”; } else { echo “chmod failed.”; } // close connection ftp_close($ftp_conn); ?> |
The ftp_chmod() function assigns permissions to a specified file on the FTP server.
ftp_chmod(ftp_conn, mode, file); |
Parameter |
Description |
ftp_conn |
Mandatory. Specifies the FTP connection to use. |
mode |
Mandatory. Specifies the new permissions, represented by four digits:
Possible values (sum these numbers to set multiple permissions):
|
file |
Mandatory. Specifies the file for which to set permissions. |
Return Value: |
The updated file permissions on success, or FALSE on failure. |
PHP Version: |
5+ |