PHP ftp_chmod()関数
例
ファイルのアクセス許可を設定します。
<?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);
?>
定義と使用法
ftp_chmod()関数は、FTP経由で指定されたファイルにアクセス許可を設定します。
構文
ftp_chmod(ftp_conn, mode, file);
パラメータ値
Parameter | Description |
---|---|
ftp_conn | 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 |
技術的な詳細
戻り値: | 成功した場合は新しいファイルのアクセス許可、失敗した場合はFALSE |
---|---|
PHPバージョン: | 5歳以上 |
❮PHPFTPリファレンス