diff --git a/app/image/upload_image.php b/app/image/upload_image.php index 308e473..ce68bc1 100644 --- a/app/image/upload_image.php +++ b/app/image/upload_image.php @@ -11,72 +11,80 @@ session_start(); include "../server/conn.php"; if (isset($_POST['submit'])) { - // Root paths - $dir = "images/"; - $thumb_dir = $dir."thumbnails/"; + if (isset($_SESSION['id'])) { + // Root paths + $dir = "../../images/"; + $thumb_dir = $dir."thumbnails/"; - // File paths - $image_basename = basename($_FILES['image']['name']); - $image_path = $dir.$image_basename; - $file_type = pathinfo($image_path,PATHINFO_EXTENSION); + // File paths + $image_basename = basename($_FILES['image']['name']); + $image_path = $dir.$image_basename; + $file_type = pathinfo($image_path,PATHINFO_EXTENSION); - // Allowed file types - $allowed_types = array('jpg', 'jpeg', 'png', 'webp'); - if (in_array($file_type, $allowed_types)) { - // Move file to server - if (move_uploaded_file($_FILES['image']['tmp_name'], $image_path)) { - // Attempt making a thumbnail - try { - $image_thumbnail = new Imagick($image_path); - $image_thumbnail->resizeImage(300,null,null,1,null); - $image_thumbnail->writeImage($thumb_dir.$image_basename); - } catch (Exception $e) { - ?> - - + // Allowed file types + $allowed_types = array('jpg', 'jpeg', 'png', 'webp'); + if (in_array($file_type, $allowed_types)) { + // Move file to server + if (move_uploaded_file($_FILES['image']['tmp_name'], $image_path)) { + // Attempt making a thumbnail + try { + $image_thumbnail = new Imagick($image_path); + $image_thumbnail->resizeImage(300,null,null,1,null); + $image_thumbnail->writeImage($thumb_dir.$image_basename); + } catch (Exception $e) { + echo " - - - + sniffleAdd(':3', 'Your Image uploaded successfully!', 'var(--green)', '".$root_dir."assets/icons/check.svg'); + + "; + } else { + echo " + + "; + } + } + } else { + echo " + + "; } } else { - ?> + echo " - + echo " - + sniffleAdd('Who are you!', 'You must be loggedin to upload things, sowwy!', 'var(--red)', '".$root_dir."assets/icons/cross.svg'); + + "; } ?> @@ -64,9 +80,9 @@
In this world you have 2 choices, to upload a really cute picture of an animal or fursuit, or something other than those 2 things.