Supported Versions: PHP 5, PHP 7, PHP 8
Set permissions on a file via FTP
<?php ftp_chmod(FTP\Connection $ftp, int $permissions, string $filename): int|false
<?php     function ftp_chmod(...$arguments)

    {

        if ( ! is_mocked('ftp_chmod')) {

            return \ftp_chmod(...$arguments);

        }



        return return_mocked_value('ftp_chmod');
<?php         $location = $this->prefixer->prefixPath($path);

        $mode = $this->visibilityConverter->forFile($visibility);



        if ( ! @ftp_chmod($this->connection(), $mode, $location)) {

            $message = error_get_last()['message'];

            throw UnableToSetVisibility::atLocation($path, $message);

        }
<?php                 throw UnableToCreateDirectory::atLocation($dirPath, $errorMessage);

            }



            if ($mode !== false && @ftp_chmod($connection, $mode, $location) === false) {

                throw UnableToCreateDirectory::atLocation($dirPath, 'unable to chmod the directory');

            }

        }