PHP ftp_chmod() Function
Definition and Usage
The ftp_chmod() function sets the permissions of the specified file on the FTP server.
If successful, the function returns the new permissions. Otherwise, it returns false.
Syntax
ftp_chmod(ftp_connection,mode,file)
Parameters | Description |
---|---|
ftp_connection | Required. Specifies the FTP connection to use (identifier of the FTP connection). |
mode | Required. Specifies the new permissions. |
file | Required. Specifies the name of the file whose permissions are to be modified. |
Example
<?php $conn = ftp_connect("ftp.testftp.com") or die("Could not connect"); ftp_login($conn,"user","pass"); // Owner can read and write, others have no permissions ftp_chmod($conn,"0600","test.txt"); // Owner can read and write, others can read ftp_chmod($conn,"0644","test.txt"); // Owner has all permissions, others can read and execute ftp_chmod($conn,"0755","test.txt"); // Owner has all permissions, the group to which the owner belongs can read ftp_chmod($conn,"0740","test.txt"); ftp_close($conn); ?>