views:

131

answers:

4
+1  Q: 

PHP mkdir issue!

Hi,

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.

A: 

dear it is due to user rights, please check the user when you are creating the any dir using mkdir function,

Chirag
but it creates the first, why not the rest?
Richard González Alberto
r u creating the sub dir's within first created directory??
Chirag
A: 

Have you tried chmoding the directories?

mkdir("photos/$cat", 0777, true);
chmod("photos", 0777);
chmod("photos/$cat", 0777);
mkdir("photos/$cat/$sku", 0777);
chmod("photos/$cat/$sku", 0777);
Arda Xi
Yep, something like that just found the problem... but not exactly like this...
Richard González Alberto
+1  A: 

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?

Richard González Alberto
A: 

http://php.net/umask

Col. Shrapnel