/** * Saves the specified file to the target directory. File data and properties * are taken from an entry in the provided files array * * @param array $filesArray * @param string $fileKey * @param string $destinationDir * @param string $destinationFile */ public static function saveFile($filesArray, $fileKey, $destinationDir, $destinationFile) { if ($filesArray[$fileKey]["name"]) { if (!file_exists($destinationDir)) { mkdir($destinationDir); } $extension = self::getExtensionForMimeType($filesArray, $fileKey); $finalFile = $destinationDir . "/" . $destinationFile . "." . $extension; //$file = $upload_path;// . $new_cnt . "." . $extension; $result = move_uploaded_file($filesArray[$fileKey]["tmp_name"], $finalFile); // TODO update this for GIF, PNG, etc. if (self::isResizableImageType($extension)) { $ds = new dropShadow(); // resize to 800 px wide IF this is a horizontal image (width > height) $ds->loadImage($finalFile); if (ImageSX($ds->_imgOrig) > ImageSY($ds->_imgOrig)) { $ds->resizeToSize(800, 0); } else { if (ImageSX($ds->_imgOrig) > 800) { $ds->resizeToSize(800, 0); } } $ds->saveFinal($finalFile); } } }
if ($page_action == "updateUser") { $tmp = realpath(".") . "/temp"; if (!file_exists($tmp)) { mkdir($tmp); } $tmpfile = $tmp . "/" . $_FILES["signature_file"]["name"]; if (move_uploaded_file($_FILES["signature_file"]["tmp_name"], $tmpfile)) { $ext = getImageExtension($_FILES["signature_file"]["type"]); //echo $ext; if ($ext == "gif") { echo "The Nerdery does not currently support .gif files for signatures. This will (hopefully) be fixed soon..."; } else { $base = realpath(".") . "/images/signatures/" . $_SESSION["user"]->userID . "."; $final = $base . $ext; $resizer = new dropShadow(true); $resizer->loadImage($tmpfile); $resizer->resizeToSize($SIGNATURE_WIDTH, 0); $resizer->saveFinal($final); copy($final, $base . "sig"); unlink($final); $_SESSION["user"]->signatureFile = 1; } } $_SESSION["user"]->displayName = $_POST["display_name"]; $_SESSION["user"]->save(); } ?> <br> <table border="0" width="750" cellpadding="0" cellspacing="0">
$ds->saveFinal("../" . $dest_path . "/" . $file); // create thumbnail $ds->resizeToSize(80, 0); $ds->saveFinal("../" . $dest_path . "/t_" . $file); $sql = "INSERT INTO AlbumItems (AlbumID, AlbumItemAuthor, CreatedDate, FileName, FileExtension, ModifiedDate) VALUES (" . $_GET["aid"] . ",'" . $_SESSION["UserID"] . "','" . date($MYSQL_DATE_FORMAT) . "','" . $file . "','" . getFileExtension($file) . "','" . date($MYSQL_DATE_FORMAT) . "')"; mysql_query($sql) or die("ERROR: " . mysql_error() . "<br>SQL: " . $sql); unlink($file); } } closedir($handle); rmdir($temp_dir); } else { $file = $_FILES["album_files"]["name"]; $ds = new dropShadow(); // resize to 800 px $ds->loadImage($file); if (ImageSX($ds->_imgOrig) > ImageSY($ds->_imgOrig)) { $ds->resizeToSize(800, 0); } else { if (ImageSX($ds->_imgOrig) > 800) { $ds->resizeToSize(800, 0); } } $ds->saveFinal("../../galleries/" . $_GET["aid"] . "/" . $file); // create thumbnail $ds->resizeToSize(80, 0); $ds->saveFinal("../../galleries/" . $_GET["aid"] . "/t_" . $file); unlink($file); $sql = "INSERT INTO AlbumItems (AlbumID, AlbumItemAuthor, CreatedDate, FileName, FileExtension, ModifiedDate) VALUES (" . $_GET["aid"] . ",'" . $_SESSION["UserID"] . "','" . date($MYSQL_DATE_FORMAT) . "','" . $_FILES["album_files"]["name"] . "','" . $fe . "','" . date($MYSQL_DATE_FORMAT) . "')"; mysql_query($sql) or die("ERROR: " . mysql_error() . "<br>SQL: " . $sql); rmdir($temp_dir);