开发者

PHP ssh2_scp_send file permissions

开发者 https://www.devze.com 2023-01-31 00:20 出处:网络
I am using the PHP function ssh2_scp_send to transfer files from one server to another. The interesting things is that if I write the permission in it\'s octal开发者_StackOverflow中文版 form (ie 0644)

I am using the PHP function ssh2_scp_send to transfer files from one server to another. The interesting things is that if I write the permission in it's octal开发者_StackOverflow中文版 form (ie 0644) directly everything works fine. If I instead enclose this in inverted commas or use a variabel this does not work any more.

To be clearer: This works: ssh2_scp_send($conn, $localFile, $remoteFile, 0644);

Does NOT work: ssh2_scp_send($conn, $localFile, $remoteFile, "0644");

Does NOT work: $permission=0644;ssh2_scp_send($conn, $localFile, $remoteFile, $permission);

Anybody has any idea why this is the case?


Give decoct() a chance. I'm not sure this will work, but you can try. One more thing you can try is to store permissions values into constants with define()


The string may be interpreted as decimal.

Also, what type is $permission? Try using var_dump() on it. It may be a string too.

$a = 0644;

$b = (int) "0644";

var_dump($a, $b); // int(420), int(644)

See it on codepad.org

0

精彩评论

暂无评论...
验证码 换一张
取 消