https://www.zaaltjeoudenbos.rf.gd
I have a form where users can upload an image to a folder uploads. But when I try uploading files larger than 3Mb, I receive a 502 Bad Gateway: nginx error.
The code I used to upload my picture is placed below. When I upload a smaller image (300Kb) it is uploaded. Is there someone who experienced something similar?
<?php
require_once('./connection.php');
// Uit te voeren wanneer het formulier wordt verzonden
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$category_id = $_POST["category_id"];
$description = $_POST["description"];
// Controleren of er een foto is geupload
if (!empty($_FILES["image"]["name"])) {
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["image"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Bestandextentie controleren
$check = getimagesize($_FILES["image"]["tmp_name"]);
if($check !== false) {
$uploadOk = 1;
} else {
echo "Het geupload bestand is geen afbeelding.";
$uploadOk = 0;
}
// Contoleren of afbeeldingen niet dubbel worden geupload
if (file_exists($target_file)) {
echo "Het bestand is reeds geupload.";
$uploadOk = 0;
}
// Groote van afbeelding controleren (10 000 000 bytes = 10 Mb)
if ($_FILES["image"]["size"] > 10000000) {
echo "Het bestand is te groot.";
$uploadOk = 0;
}
// Controle op bestandstype
if($imageFileType != "JPG" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
echo "Enkel bestanden van type: jpg, png of jpeg.";
$uploadOk = 0;
}
// Als de upload niet voltooid is:
if ($uploadOk == 0) {
echo $uploadOk;
echo "Het bestand is niet geupload.";
// Bestand uploaden als alles ok is
} else {
echo '<script>console.log("ok"); </script>';
if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
// Pad in de databank opslaan
$sql = "INSERT INTO photos (category_id, path, description) VALUES ('$category_id', '$target_file', '$description')";
if (mysqli_query($conn, $sql)) {
echo "De foto is met succes toegevoegd aan de foto gallerij";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
} else {
echo "Er is een fout ontstaan tijdens het uploaden van uw foto.";
}
}
}
}