$newTag->execute(); } } else { $fileUpdate->setTags($file->getTags()); } $fileUpdate->setType(issetOrBlank($_POST['file-type'])); $fileUpdate->setUploadDate($file->getUploadDate()); //see if active has changed //alias - see if it $fileUpdate->setActive(issetOrBlank($_POST['file-active']) == "" ? 0 : 1); if (!isset($_FILES["file-file"])) { //no new file $fileUpdate->setUploader($file->getUploader()); $fileUpdate->setSize($file->getSize()); $fileUpdate->setContentType($file->getContentType()); $fileUpdate->setExtension($file->getExtension()); $fileUpdate->setPath($file->getPath()); } else { //$file->setUploader( ($_SESSION['username'] != "" ? $_SESSION['username'] : '******' ); //from session? //$file->setSize($_FILES["file-file"]['size']); //$file->setContentType( issetOrBlank($_FILES["file-file"]['type']) ); //$file->setExtension( pathinfo($_FILES["file-file"]['name'], PATHINFO_EXTENSION) ); //delete existing file } $fileAlias = issetOrBlank($_POST['file-alias']); if (!startsWith($fileAlias, "/")) { $fileAlias = "/" . $fileAlias; } // echo "Alias: ".$file->getAliasID(); // echo "Alias Text: ".$fileAlias; //check if alias is new or changed.
//file uploaded $targetFile = UPLOADS_DIR . $uploadTo . $_FILES["file-file"]['name']; if (!file_exists($targetFile)) { if (move_uploaded_file($_FILES["file-file"]["tmp_name"], issetOrBlank($targetFile))) { $uploaded = 1; } } else { echo '<h1 class="error">File already Exists!</h1>'; $fileUploadPath = WEB_ROOT . DIRECTORY_SEPARATOR . UPLOAD_FOLDER_NAME . DIRECTORY_SEPARATOR . $uploadTo . issetOrBlank($_FILES["file-file"]['name']); //$fileUploadPath = str_replace('//','/',$fileUploadPath); echo '<p>Link: <a href="' . $fileUploadPath . '">' . $_FILES["file-file"]['name'] . '</a></p>'; } $file->setPath($uploadTo . issetOrBlank($_FILES["file-file"]['name'])); $file->setSize($_FILES["file-file"]['size']); $file->setContentType(issetOrBlank($_FILES["file-file"]['type'])); $file->setExtension(pathinfo($_FILES["file-file"]['name'], PATHINFO_EXTENSION)); } } if ($uploaded == 1) { $file->setUploader($_SESSION['username'] != "" ? $_SESSION['username'] : '******'); //from session? if ($file->getExpiry() == "") { $file->setExpiry("0000-00-00 00:00:00"); } if ($file->save() > 0) { echo '<h1>File Uploaded OK!</h1>'; } else { echo '<h1>Failure Uploading File</h1>'; pa($file); } if (issetOrBlank($_POST['file-alias']) != "") {