Hàm ftp_chmod () trong PHP
Thí dụ
Đặt quyền đối với tệp:
<?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);
?>
Định nghĩa và Cách sử dụng
Hàm ftp_chmod () đặt quyền trên tệp được chỉ định thông qua FTP.
Cú pháp
ftp_chmod(ftp_conn, mode, file);
Giá trị tham số
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 |
Chi tiết kỹ thuật
Giá trị trả lại: | Quyền đối với tệp mới nếu thành công, FALSE nếu không thành công |
---|---|
Phiên bản PHP: | 5+ |
❮ Tham chiếu FTP PHP