Search code examples
phpdirectorychmodmodemkdir

Need Help Setting Chmod Permissions on New Directory via PHP


I am using PHP's mkdir function and I am having some difficulty with the $mode parameters. If I don't specify a parameter, I get UNIX 755 as the default permission settings of the new directory. I would like to set the permission to be UNIX 777, so I did that as you see here:

$mode = '0700';
mkdir($newdir, $mode);

When I do this a folder is created, but I cannot do anything with it. In fact I cannot even delete it! All I can do is rename it via FTP...

I then tried setting $mode = '0600'; This makes a workable folder, but the permissions are set to UNIX 110. How is this possible? Shouldn't it be a UNIX value of 600? Is there some conversion that I am missing out here? Thanks.


Solution

  • The mode is supposed to be a number, not a string. Try $mode = 0700; instead.