Untested
<?php
// Base path starts with attachments
$upload_path = "attachments/";
// Check if the year directory exists, if not, create it
if(is_dir($upload_path.date("Y")))
$upload_path .= date("Y")."/";
else {
mkdir($upload_path.date("Y"));
$upload_path .= date("Y")."/";
}
// Next, check the month by word
if(is_dir($upload_path.date("F"))
$upload_path .= date("F")."/";
else {
mkdir($upload_path.date("F"));
$upload_path .= date("F")."/";
}
// Next check the day of the month with leading zeros
if(is_dir($upload_path.date("d"))
$upload_path .= date("d")."/";
else {
mkdir($upload_path.date("d"));
$upload_path .= date("d")."/";
}
echo $upload_path;
?>
That should get your upload path created if it doesn't exist, or use it if it does. The path should be accessible through the $upload_path variable.