Victory is mine, well yours, to be fair

Turns out Breezer’s script was happily creating folders here :
westcoastestates/Aplications/MAMP/htdocs/westcoastestates/assets/images/’.$docid.’
By removing
$modx->config['base_path'].
from the $dir variable it’s now creating in the westcoastestates/assets/images/ folder.
Many thanks to everyone, special thanks to Breezer.
Now I’ll have to add an IF statement to limit it to certain templates.
Final code that creates a new folder only for templates 5 or 3 :
$e = &$modx->Event;
$docid = $e->params['id'];
$dir = $modx->config['rb_base_dir']."images/".$docid;
$folder_permissions = octdec($modx->config['new_folder_permissions']);
function mkdirs($strPath, $mode){ // recursive mkdir function
if (is_dir($strPath)) return true;
$pStrPath = dirname($strPath);
if (!mkdirs($pStrPath, $mode)) return false;
return @mkdir($strPath);
}
switch ($e->name) {
case "OnDocFormSave":
if($_REQUEST['template'] == 5 || $_REQUEST['template'] == 3)
{
$old_umask = umask(0);
mkdirs($dir,$folder_permissions);
umask($old_umask);
}
break;
default: "";
return;
}