I tried $sftp->chmod('0755', "file.zip");
and $sftp->chmod('0755', "file.zip");
But in both cases the permission has been set to 363 instead.
At a guess the permissions are 1363. In other words octal(755). It's a complete guess, but I would suggest that the chmod function is taking a decimal mode, rather than an octal one.
0755 and '0755' are not the same thing as demonstrated thusly:
<?php echo '0755' == 0755 ? 'equal' : 'not equal'; ?>;
Per that, try removing the single quotes around 0755.
The reason phpseclib expects permissions to be represented as an octal value ('0755' is cast to a decimal value - not an octal one) is because that's how ftp_chmod
does it and that's what Net_SFTP::chmod()
is modeled after. (actually, pretty much all of phpseclib's SFTP API is modeled after PHP's FTP extension API)
You can use
$sftp->chmod(0755, $file);
You should not input permissions into the phpseclib chmod()
function as a string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.