How can the parameters of ftp_chmod in PHP be adjusted to ensure successful directory permission setting?

To ensure successful directory permission setting using ftp_chmod in PHP, you need to make sure that you are providing the correct parameters to the function. The first parameter should be the FTP connection resource, the second parameter should be the permissions in octal format (e.g., 0755 for read, write, and execute permissions for owner and read and execute permissions for group and others), and the third parameter should be the directory path.

// FTP connection
$ftp_server = 'ftp.example.com';
$ftp_user = 'username';
$ftp_pass = 'password';
$ftp_conn = ftp_connect($ftp_server);
ftp_login($ftp_conn, $ftp_user, $ftp_pass);

// Directory path and permissions
$dir_path = '/path/to/directory';
$permissions = 0755;

// Set directory permissions
if (ftp_chmod($ftp_conn, $permissions, $dir_path)) {
    echo "Directory permissions set successfully";
} else {
    echo "Failed to set directory permissions";
}

// Close FTP connection
ftp_close($ftp_conn);