$hans problems with file upload

27 views Asked by At

Someone got an idea why my file cannot be moved?

$uploadDir = "images/";

if(isset($_POST['add_product'])) {

    $name = $_POST['name'];
    $description = $_POST['description'];
    $price = $_POST['price'];
    $uploadedImage = $uploadDir . basename($_FILES['image']['name']);

    if($_FILES['image']['error'] == UPLOAD_ERR_OK && move_uploaded_file($_FILES['image']['tmp_name'], $uploadedImage)) {
        $image = basename($_FILES['image']['name']);
    }

    // Produkt anlegen, public muss nicht mitgegeben werden, da DEFAULT gesetzt wird
    $stmt = $db->prepare("INSERT INTO products (name, description, price, image) VALUES (?, ?, ?, ?)");
    if($stmt->execute([$name, $description, $price, $image])) {
        $msg = "Produkt erfolgreich hinzugefĆ¼gt & freigegeben!";
    } else {
        $msg = "Fehler bei Produktanlage!";
    }
}

I have checked syntax, aswell as permissions on the correspondig folder

0

There are 0 answers