Permissions for PHP files ssh2_scp_send

I use the ssh2_scp_send PHP ssh2_scp_send to transfer files from one server to another. The interesting thing is that if I write the resolution in octal form (i.e. 0644), then everything works fine. If I instead put it in quotation marks or used a variable, this no longer works.

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

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

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

Does anyone know why this is so?

+4
source share
2 answers

Give decoct() chance. I'm not sure this will work, but you can try. Another thing you can try is to store permission values ​​in constants with define()

+2
source

The string can be interpreted as decimal.

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

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

Take a look at codepad.org

+1
source

Source: https://habr.com/ru/post/1332570/


All Articles