CakeFest 2024: The Official CakePHP Conference

ssh2_sftp_chmod

(PECL ssh2 >= 0.12)

ssh2_sftp_chmodファイルのモードを変更する

説明

ssh2_sftp_chmod(resource $sftp, string $filename, int $mode): bool

指定したファイルのモードの mode への変更を試みます。

パラメータ

sftp

SSH2 SFTP リソース。ssh2_sftp() で開いたもの。

filename

ファイルへのパス。

mode

ファイルのパーミッション。このパラメータの詳細は chmod() を参照ください。

戻り値

成功した場合に true を、失敗した場合に false を返します。

例1 リモートサーバー上でのファイルのモード変更

<?php
$connection
= ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
$sftp = ssh2_sftp($connection);

ssh2_sftp_chmod($sftp, '/somedir/somefile', 0755);
?>

参考

add a note

User Contributed Notes 1 note

up
1
boris at brdaric dot com
4 years ago
It seems that when creating directory using this function, permissions are affected by the system umask setting.

If you want to make sure proper permissions are set, after creating directory, set permissions by using ssh2_​sftp_​chmod function.
To Top