Jump to content

CHMOD - sending the right value


grissom

Recommended Posts

Hi all, I'm trying to modify some permissions on my server in PHP.

 

At first, I hit a small stumbling block in that ftp_chmod was not installed in the version of PHP on my server. Bummer.

 

However, after a bit of hunting around phpfreaks, I found this previous answer in an earlier topic which I've implemented in my bit of code

 

if (!function_exists('ftp_chmod')) {
   function ftp_chmod($ftp_stream, $mode, $filename)  {
       return ftp_site($ftp_stream, sprintf('CHMOD %o %s', $mode, $filename));
       }
   }

 

One frustrating problem is that the permission which gets set is not the permission I try to set it to.

 

For example, calling ftp_chmod($conn, '0777', $filename) sets the permission to 710, not 777 !!!

 

I suspect it may be something to do with decimal to octal conversion but I'm really scratching my head.

 

When I changed the function to %i instead of %o, it made it worse and trying to set 777 ended up setting it to 700 !

 

I bet the answer is obvious when you know how, but it's getting me foxed.  I'd be really grateful of any help.

 

 

Link to comment
https://forums.phpfreaks.com/topic/160475-chmod-sending-the-right-value/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.