I have this code to create recursive directories:
define('_PATH', '/www/virtual/user/galleries');
$gallery_path = "/".intval($gallery['id']);
if(!is_dir(_PATH.$gallery_path))
mkdir(_PATH.$gallery_path, 0777, false);
I made the parent directory ('galleries') writable (0777). I can confirm that the directory is created. However, it is NOT created with 0777 permissions, but with 0755! I have no explanation for this. :-(