$addTags = array_diff($newTags, $tags); $pos = sizeof($tags); foreach ($addTags as $tag) { $pos++; $newTag = $conn->prepare("INSERT INTO `fileupload`.`options` (`group_id`, `option`, `sort`) VALUES ('4', :tag, :pos)"); $newTag->bindParam(':tag', trim($tag)); $newTag->bindParam(':pos', $pos); $newTag->execute(); } $file->setType(issetOrBlank($_POST['file-type'])); $file->setUploadDate(date('Y-m-d H:i:s')); $file->setActive(1); $file->setAliasID(0); //echo UPLOADS_DIR; $DATEPATH = date('Y') . DIRECTORY_SEPARATOR . date('m') . DIRECTORY_SEPARATOR; $uploadTo = $DATEPATH . $file->getCampus() . DIRECTORY_SEPARATOR . $file->getFaculty() . DIRECTORY_SEPARATOR . $file->getCategory() . DIRECTORY_SEPARATOR; $uploadTo = issetOrBlank($uploadTo); //$uploadTo = ""; //echo $uploadTo; //Ensure that the directory path exists //echo UPLOADS_DIR; //exit; mkpath(UPLOADS_DIR . $uploadTo); //echo UPLOADS_DIR.$uploadTo; $uploaded = 0; if (!file_exists(UPLOADS_DIR . $uploadTo)) { //could not create directory echo '<h1 class="error">Could not create directory for upload</h1>'; } else { if (isset($_FILES["file-file"])) { //file uploaded