Jump to content

faild to create path with chmod 777


hueman

Recommended Posts

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.