tags:

views:

89

answers:

2

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

+1  A: 

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.

Douglas Leeder
A look through the file at http://www.frostjedi.com/terra/SFTP.txt tells me it is indeed binary. +1
Gausie
A: 

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)

terrafrost