PHP ftp_chmod()Functions
Complete PHP FTP Reference Manual
Definition and Usage
The ftp_chmod() function sets permissions for a specified file on the FTP server.
If successful, the function returns the new permissions. If it fails, it returns FALSE and a warning.
Syntax
ftp_chmod(ftp_connection,mode,file)
| Parameters | Description |
|---|---|
| ftp_connection | Required. Specifies the FTP connection to use. |
| mode | Required. Specifies the new permissions. The mode parameter consists of 4 numbers:
Possible values (to set multiple permissions, total the numbers below):
|
| 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");
// 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);
?>
$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 Manual Other Extensions