From the usernotes in [man]mkdir[/man] I stole the following:
function MakeDirectory($dir, $mode = 0755)
{
if (is_dir($dir) || @mkdir($dir,$mode))
{return TRUE;} else {return FALSE;};
}
When you try and upload a file, you take the path to the base-directory, and add the name of the folder (e.g., $path."/".$year."/"$month) and you pass this to the function. It will return true if the directory exists, or if it has created it. Either one is ok.