PHP ftp_chmod() Function
Example
Set 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);
?>
Definition and Usage
The ftp_chmod() function sets permissions on the specified file via FTP.
Syntax
ftp_chmod(ftp_connection,mode,file);
Parameter | Description |
---|---|
ftp_connection | Required. Specifies the FTP connection to use |
mode | Required. Specifies the new permissions. This parameter consists of four numbers:
Possible values (to set multiple permissions, add up the following numbers):
|
file | Required. Specifies the file to set permissions on |
Technical Details
Return Value: | Returns the new file permissions on success or FALSE on failure |
---|---|
PHP Version: | 5+ |
PHP FTP Reference