0

I'm developing a custom tshirt lab. I want to be able to save a user's uploaded image in a folder as well as make an entry in a table with its image path and id. It gets moved to the folder, but it doesn't get inserted. No errors show up as well, so I'm completely stumped on why it's not working. I'm using session variables i had declared in another page and I still don't get any errors.

<?php
session_start();
$conn = new mysqli("localhost","root","asdasd","asdsada");

$UPLOAD_DIR = 'uploads/';
$img = $_POST['imgData'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = $UPLOAD_DIR . time() . '.png';
$_SESSION["design_path"] = $file;
$success = file_put_contents($file, $data);
$query_upload = "INSERT INTO design (image_id, customer_id, design_path, image_path) VALUES ('$_SESSION["image_id"]', '$_SESSION["customer_id"]', '$file', '$_SESSION["image_path"]')";
$result=mysqli_query($conn,$query_upload);
if($result){
    echo "design saved";
}
?>

0 Answers0