PHP ftp_chmod() Function
Complete PHP FTP Reference:
Definition and Usage
The ftp_chmod() function sets permissions for a file on the FTP server.
If successful, this function returns the new permissions. If it fails, it returns FALSE and a warning.
Syntax
ftp_chmod(ftp_connection, mode, file)
Parameters
| Parameter | Description |
|---|---|
| ftp_connection | Required. Specifies the FTP connection to use. |
| mode | Required. Specifies the new permissions. The mode parameter consists of 4 digits: * The first digit is usually 0 * The second digit specifies permissions for the owner * The third digit specifies permissions for the owner's group * The fourth digit specifies permissions for everyone else Possible values (sum the numbers below if you need to set multiple permissions): * 1 = execute permission * 2 = write permission * 4 = read permission |
| file | Required. Specifies the name of the file to change permissions for. |
Example
<?php
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"user","pass");
// Read and write for owner, nothing for everybody else
ftp_chmod($conn,"0600","test.txt");
// Read and write for owner, read for everybody else
ftp_chmod($conn,"0644","test.txt");
// Everything for owner, read and execute for everybody else
ftp_chmod($conn,"0755","test.txt");
// Everything for owner, read for owner's group
ftp_chmod($conn,"0740","test.txt");
ftp_close($conn);
?>
Complete PHP FTP Reference:
YouTip