Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi Guys,
I currently have this code:
".$tab, 0777);

wen the directory is created it only has the permissons 755, any ideas why
this is this case?

Kathryn (Fire Juggler)

Re: permissions

<Sat, 9 Jul 2005 17:26:06 +0100>

Quoted text here. Click to load it

I seem to recall somebody from 34sp saying its only the first 7 thats  
important .

Try 0766

Re: permissions

Fire Juggler wrote:
Quoted text here. Click to load it
I thought it was a bug.

just chmod to 0777 after making the dir.

function makedir($dir,$mode=0777){
   return chmod($dir,$permission);

Re: permissions

Fire Juggler wrote:
Quoted text here. Click to load it
At the PHP documentation you'll find this:

You might notice that when you create a new directory using this code:

mkdir($dir, 0777);

The created folder actually has permissions of 0755, instead of the  
0777. Why is this you ask? Because of umask():

The default value of umask, at least on my setup, is 18. Which is 22  
octal, or
0022. This means that when you use mkdir() to CHMOD the created folder  
to 0777,
PHP takes 0777 and substracts the current value of umask, in our case  
0022, so
the result is 0755 - which is not what you wanted, probably.

The "fix" for this is simple, include this line:

$old_umask = umask(0);

Right before creating a folder with mkdir() to have the actual value you  
put be
used as the CHMOD. If you would like to return umask to its original  
value when
you're done, use this:


Site Timeline