hueman Posted June 5, 2010 Share Posted June 5, 2010 i need to create nested directories with chmod 777, i tried following code but every directory created with chmod 755 in CentOS, in windows this code create directories with chmod 777, whats the problem? $dir = "a"; $folders = array('b','c','d'); foreach($folders as $f) { $dir = $dir."/".$f; if(!is_dir($dir)) { if(mkdir($dir)) echo $f.' was created<br>'; else echo 'failed to create '.$F.'<br>'; if(chmod($dir, 0777)) echo $F.' chmod convert to 777<br>'; else echo 'failed to convert '.$F.' chmod to 777<br>'; } } i tried to create my path (eg: 'a/b/c/d') with mkdir('a/b/c/d',0777,true) but this code create directories with chmod 755 too, i didnt success to convert chmod to 777 by applying chmod() to every directories, what can i do to create a path like 'a/b/c/d' with chmod 777 for every directories in CentOS? Quote Link to comment https://forums.phpfreaks.com/topic/203990-faild-to-create-path-with-chmod-777/ Share on other sites More sharing options...
dabaR Posted June 6, 2010 Share Posted June 6, 2010 From http://ca2.php.net/chmod Note: The current user is the user under which PHP runs. It is probably not the same user you use for normal shell or FTP access. The mode can be changed only by user who owns the file on most systems. Do you know how to check for this? Do you have full control over this server, or is this a hosting company's server? Quote Link to comment https://forums.phpfreaks.com/topic/203990-faild-to-create-path-with-chmod-777/#findComment-1068454 Share on other sites More sharing options...
hueman Posted June 6, 2010 Author Share Posted June 6, 2010 thank you for responding me i am familiar with chmod() i have full control over my server, should i change some php settings for working chmod() correctly through all path's folders? Quote Link to comment https://forums.phpfreaks.com/topic/203990-faild-to-create-path-with-chmod-777/#findComment-1068488 Share on other sites More sharing options...
dabaR Posted June 6, 2010 Share Posted June 6, 2010 Find out which server is running the web server (usually 'nobody' or 'www-data'), and which user is the owner of the directory where you are creating a/b/c/d. If they are not the same, that is your problem. Quote Link to comment https://forums.phpfreaks.com/topic/203990-faild-to-create-path-with-chmod-777/#findComment-1068526 Share on other sites More sharing options...
hueman Posted June 6, 2010 Author Share Posted June 6, 2010 thank you so much, according to your guide i test several scripts on a folder was created manually by cuteftp and a folder was created by a php script i am able to do anything over folder that was created by cuteftp but about another folder i dont able to do somethings cuteftp tells me the owner of first folder is a user that calls my site name (for eg: example.com) and about second folder tells me the owner is apache i am using parallels plesk how can i change the owner of folders that created by php? thank you again my friend Quote Link to comment https://forums.phpfreaks.com/topic/203990-faild-to-create-path-with-chmod-777/#findComment-1068705 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.