Example 1 — Change Permissions with SITE CHMOD
Use ftp_site() to set a file to 0644 on the server.
<?php
$ftp = ftp_connect('ftp.example.com');
ftp_login($ftp, 'demo', 'secret');
if (ftp_site($ftp, 'CHMOD 0644 index.html')) {
echo "Permissions updated", PHP_EOL;
} else {
echo "SITE command failed", PHP_EOL;
}
ftp_close($ftp); How It Works
- You do not type the word SITE yourself. ftp_site() adds it for you.
- The command CHMOD 0644 index. html is sent to the server.
- A supporting server changes the permissions and replies with success.
- ftp_site() returns true and the message is printed.

