Search code examples
phppermissionsfile-permissionsmkdir

PHP mkdir issue!


I trying to create some dirs like this:

@mkdir("photos/$cat/$sku", 0777, true)

it creates the first directory with 0777 permissions, but when it creates the second is uses 000 as it's perms, so it fails to create the third.

A workaround this please?

Thanks, Richard.


Solution

  • This solved the issue:

    $a = @mkdir("photos/$cat/", 0777);
        @chmod("photos/$cat/", 0777);
        $b = @mkdir("photos/$cat/$sku/", 0777);
        @chmod("photos/$cat/$sku/", 0777);
    

    but why can't use recursive on mkdir?