php8.5
Home/ Manual/ ftp / functions/ ftp_site

ftp_site

PHP function Edit on GitHub ✎

(PHP 4, PHP 5, PHP 7, PHP 8)

Sends a SITE command to the server

Description

ftp_site(FTP\Connection $ftp, string $command): bool

ftp_site() sends the given SITE command to the FTP server.

SITE commands are not standardized, and vary from server to server. They are useful for handling such things as file permissions and group membership.

Parameters

ftp

Ftp

command

The SITE command. Note that this parameter isn't escaped so there may be some issues with filenames containing spaces and other characters.

Return Values

Success

Changelog

VersionDescription

Examples

Sending a SITE command to an ftp server

php
<?php
// Connect to FTP server
$ftp = ftp_connect('ftp.example.com');
if (!$ftp) die('Unable to connect to ftp.example.com');

// Login as "user" with password "pass"
if (!ftp_login($ftp, 'user', 'pass')) die('Error logging into ftp.example.com');

// Issue: "SITE CHMOD 0600 /home/user/privatefile" command to ftp server
if (ftp_site($ftp, 'CHMOD 0600 /home/user/privatefile')) {
   echo "Command executed successfully.\n";
} else {
   die('Command failed.');
}
?>

See Also

Source: reference/ftp/functions/ftp-site.xml · from the official PHP manual (php/doc-en)