I am trying to save images in my database with PHP prepared statements but I run into problems. Below is my new code sample:
$dbc = mysqli_connect($dbHost, $dbUser, $dbPass, $dbName);
$image = $_FILES['picture']['name'];
$tempPath = $_FILES['picture']['tmp_name'];
$uploadDir = 'uploads/';
if (!is_dir($uploadDir)) {
mkdir($uploadDir, 0755, true);
}
move_uploaded_file($tempPath, $uploadDir . $image);
$sql = "INSERT INTO photos (user_name, user_email, image_file) VALUES (?, ?, ?);";
$stmt = mysqli_prepare($dbc, $sql);
mysqli_stmt_bind_param($stmt, "sss", $_POST['username'], $_POST['email'], $image);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
mysqli_close($dbc);