From 0932cad5d1510e061a1deb2912ea821c017f542e Mon Sep 17 00:00:00 2001 From: Fascinated Date: Sat, 15 Apr 2023 19:45:50 +0100 Subject: [PATCH] make errors less ugly --- upload.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/upload.php b/upload.php index e26abd5..61d9ca3 100644 --- a/upload.php +++ b/upload.php @@ -36,7 +36,7 @@ try { $map = $_FILES["map"]; // the file to upload if (!isset($map)) { // if the file is not set - echo "No file was uploaded"; + header("Location: /?map=No file was uploaded"); die(); } @@ -45,12 +45,12 @@ try { $size = $map["size"]; // the size of the file if ($size > 100000000) { // if the file is larger than 100MB - echo "The file is too large"; + header("Location: /?map=File is too large"); die(); } if (!isValidBeatSaberMap($file)) { - echo "The file is not a valid BeatSaber map"; + header("Location: /?map=This is not a valid BeatSaber map"); die(); } @@ -76,12 +76,10 @@ try { $target_file = $target_dir . $mapId . ".zip"; // the output file path if (!move_uploaded_file($file, $target_file)) { error_log("Error: Failed to move uploaded file from $file to $target_file"); - echo "There was an error uploading the file"; + header("Location: /?map=Failed to upload file"); die(); } - error_log("Uploaded file moved from $file to $target_file"); - header("Location: /?map=https://wip.fascinated.cc/maps/" . $mapId . ".zip"); } catch (Exception $e) { echo "There was an error uploading the file. Error: " . $e->getMessage();