grissom Posted June 1, 2009 Share Posted June 1, 2009 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 More sharing options...
grissom Posted June 1, 2009 Author Share Posted June 1, 2009 Anybody ? Link to comment https://forums.phpfreaks.com/topic/160475-chmod-sending-the-right-value/#findComment-846902 Share on other sites More sharing options...
grissom Posted June 1, 2009 Author Share Posted June 1, 2009 Sorted it myself The guy who wrote the original code made a mistake. It should be %u not %o (unsigned integer not octal) Link to comment https://forums.phpfreaks.com/topic/160475-chmod-sending-the-right-value/#findComment-846924 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.