header("Location: index.php"); } } elseif (isset($_POST['logout'])) { //NOT NEEDED FOR OUR IMPLEMENTATION OF LOGOUT session_start(); // to ensure you are using same session session_destroy(); // destroy the session so $SESSION['anything'] is not set header("Location: index.php"); } elseif (isset($_POST['newTitle'])) { $title = htmlspecialchars(trim($_POST['newTitle'])); //UPLOAD IMAGE if (!isset($_FILES['file']['error']) || $_FILES['file']['error'] !== UPLOAD_ERR_OK) { die("Upload failed with error"); } if (!$modelMethods->isPNG($_FILES['file']['tmp_name'])) { die("Cannot upload the file as it is not a PNG file"); } $fileTitle = preg_replace('/[^A-Za-z0-9 _ .-]/', '', $title); //changes into filesafe naming form $target_dir = "C:/xampp/htdocs/github/337final/uploads/"; //replace with your own absolute path to the upload folder, also make sure to modify permissions $target_file = $target_dir . $fileTitle . ".png"; $uploadOk = 1; // if file already exists if (file_exists($target_file)) { echo "File already exists."; $uploadOk = 0; } // if $uploadOk is set to 0 if ($uploadOk == 0) {