$sub = 6; } else { $sub = $num - 1; } $WeekMon = mktime(0, 0, 0, date("m", $now), date("d", $now) - $sub, date("Y", $now)); //monday week begin calculation $todayh = getdate($WeekMon); //monday week begin reconvert $d = $todayh['mday']; $m = $todayh['mon']; $y = $todayh['year']; $newFilePath = PATH_PREFIX . "{$d}-{$m}-{$y}/" . $_SESSION['Username'] . "/" . $_FILES['attachment']['name'][$i]; // Make the folder if it doesn't exist. if (!is_dir(PATH_PREFIX . "{$d}-{$m}-{$y}/" . $_SESSION['Username'] . "/") && !mkdir(PATH_PREFIX . "{$d}-{$m}-{$y}/" . $_SESSION['Username'] . "/")) { onError("onSubmitPinkie failed", "Error creating folder: " . PATH_PREFIX . "{$d}-{$m}-{$y}/" . $_SESSION['Username'] . "/"); } //Upload the file into the temp dir if (move_uploaded_file($tmpFilePath, $newFilePath)) { //Handle other code here $_pinkie->addAttachment($newFilePath); } else { onError("onSubmitPinkie", "Failed to submit pinkie because file upload failed. Path was: " . $newFilePath); } } } //------------------------------------------------------------------------------ // push it to the database. //var_dump($_pinkie); $_pinkie->toDatabase(); logGeneral($_pinkie->i_PinkieID, $_SESSION['Username'], "Pinkie was created by: " . getName()); header("Location: ./home.php");