diff --git a/dropload.php b/dropload.php index 0b0518a..a185a13 100644 --- a/dropload.php +++ b/dropload.php @@ -1,8 +1,8 @@ 6291456) { $uploadOk = 0; - header('HTTP/1.1 400 Bad Request', true, 400); - http_response_code(400); + header('HTTP/1.1 413 Payload Too Large', true, 413); + http_response_code(413); return; } // Allow only certain file formats. @@ -41,8 +41,8 @@ if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg && $imageFileType != "gif" && $imageFileType != "svg" && $imageFileType != "GIF" && $imageFileType != "SVG" ) { $uploadOk = 0; - header('HTTP/1.1 400 Bad Request', true, 400); - http_response_code(400); + header('HTTP/1.1 415 Unsupported Media Type', true, 415); + http_response_code(415); return; } // Check if $uploadOk is set to 0 by an error, if so go to failure condition. @@ -109,8 +109,8 @@ if ($uploadOk == 0) { ]); return; } else { - header('HTTP/1.1 400 Bad Request', true, 400); - http_response_code(400); + header('HTTP/1.1 422 Unprocessable Entity', true, 422); + http_response_code(422); return; } } diff --git a/upload.php b/upload.php index f57cb09..d184e98 100644 --- a/upload.php +++ b/upload.php @@ -1,8 +1,8 @@ 6291456) { - echo "Sorry, your file is too large. (Max is 6MB)"; + //echo "Sorry, your file is too large. (Max is 6MB)"; + //header("HTTP/1.1 413 Payload Too Large"); + //header('Location: ./failed.php?error=413'); + $errCode = 413; $uploadOk = 0; - header('Location: ./failed.php'); } // Allow only certain file formats. // 1.1a -- Fixed uppercase rejection bug and allows them. @@ -38,14 +44,21 @@ if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg && $imageFileType != "JPG" && $imageFileType != "PNG" && $imageFileType != "JPEG" && $imageFileType != "gif" && $imageFileType != "svg" && $imageFileType != "GIF" && $imageFileType != "SVG" ) { - echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; + //echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; + //header("HTTP/1.1 415 Unsupported Media Type"); + //header('Location: ./failed.php?error=415'); + $errCode = 415; $uploadOk = 0; - header('Location: ./failed.php'); } // Check if $uploadOk is set to 0 by an error, if so go to failure condition. if ($uploadOk == 0) { - echo "Sorry, your file could not be uploaded."; - header('Location: ./failed.php'); + if (!$errCode) { + //echo "Sorry, your file could not be uploaded."; + header('Location: ./failed.php?error=400'); + } else { + //echo "Sorry, your file could not be uploaded."; + header('Location: ./failed.php?error=' . $errCode); + } // If everything is ok, try to upload file. } else { // 1.2a --- Changed some case-confusing characters such as I and O to web safe symbols. @@ -97,14 +110,15 @@ if ($uploadOk == 0) { $newtarget = $target_dir . $newfilename; if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $newtarget)) { chmod("$newtarget", 0775); // Set read and write permissions on file - echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; + //echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; $uploaderlog = "" . date('U') . ", ". date('Y-m-d H:i:s e') . ", $_SERVER[REMOTE_ADDR], $newfilename" . ", " . $imejicoreversion . ", $_SERVER[HTTP_USER_AGENT]"; file_put_contents('uploads.log', $uploaderlog . PHP_EOL, FILE_APPEND); header('Location: https://i.yandols.xyz/' . $newfilename); } else { // If anything wrong here, go to failure condition. - echo "Sorry, there was a problem uploading your file."; - header('Location: ./failed.php'); + //echo "Sorry, there was a problem uploading your file."; + // This part of code should never occur. But in case it does, redirect user to error page with code 500. + header('Location: ./failed.php?error=500'); } } ?>