2

Possible Duplicate:
PHP mkdir and apache ownership

EDITED TO REFLECT NEW PROBLEM:

Thanks to your help I can create a directory within a directory recursively, but I am unable to create multiple folders within those created folders.

Code:

$timelineID = trim(mysql_prep($_POST['timelineID']));
mkdir("timelines/{$timelineID}/audio", 0777, true);
mkdir("timelines/{$timelineID}/image", 0777, true);
mkdir("timelines/{$timelineID}/product", 0777, true);

Again, the first mkdir() executes successfully, the second one does NOT.

Error: Warning: mkdir() [function.mkdir]: SAFE MODE Restriction in effect. The script whose uid/gid is 206601/206601 is not allowed to access (the directory I just made) owned by uid/gid 25000/25000 in (file.php) on line 13

Community
  • 1
  • 1
Daniel F. Dietzel
  • 147
  • 1
  • 2
  • 11
  • 1
    Have your tried: `mkdir("timelines/{$timelineID}/audio", 0777, true);`? Without the umask? With true the dirs are created recursively. – Green Black Dec 04 '12 at 22:26
  • Also check you have "just made that directory" and didn't create it in FTP/SSH first. – Robbie Dec 04 '12 at 22:28
  • That works for one directory, thanks! but it doesn't work for multiple... here is my code for multiple... the first one works the others fail – Daniel F. Dietzel Dec 04 '12 at 22:33
  • mkdir("timelines/{$timelineID}/audio", 0777, true); mkdir("timelines/{$timelineID}/image", 0777, true); mkdir("timelines/{$timelineID}/product", 0777, true); – Daniel F. Dietzel Dec 04 '12 at 22:33
  • What OS and version of PHP are you using ? – Baba Dec 04 '12 at 22:41
  • What @Robbie is saying is this: is it possible that `timelines/${timelineID}` already exists? If so, that first `mkdir()` call won't change the owner or permissions. – Mark Reed Dec 04 '12 at 22:44

1 Answers1

0
mkdir(path,mode,recursive,context)

with recursive and context being optional params

e.g.

mkdir("timelines/{$timelineID}/audio", 0777, true);

works on PHP 5+

see: http://php.net/manual/en/function.mkdir.php

Oliver Atkinson
  • 7,970
  • 32
  • 43
  • we got that to work, but it doesn't work for multiple folder creations. – Daniel F. Dietzel Dec 04 '12 at 22:37
  • Perhaps you have a umask issue? Did you check the permissions on the automatically-created intermediate directory? You could try clearing the umask with `$old = umask(0);` before the `mkdir` call to see if that's the problem (and `umask($old)` afterward to restore it). – Mark Reed Dec 04 '12 at 22:46