i am fairly new to PHP and SQL, and facing a problem that i am not able to find a solution for.
I am trying to upload and image to a mysql database, using this PHP code:
$fileName = $_FILES['file']['name'];
$fileTmpName = $_FILES['file']['tmp_name'];
include 'dbh.php';
$fileData = file_get_contents($fileTmpName);
$sql = "INSERT INTO images (name, data) VALUES ('$fileName', '$fileData')";
mysqli_query($conn, $sql);
mysqli_close($conn);
The result is that the database doesn't change at all.
If instead of $fileData i just insert a random value (e.g. "INSERT INTO images (name, data) VALUES ('$fileName', 'test')"
) it inserts the values into the database, so the problem must be $fileData is guess.
The type of the column data is blob, i also tried longblob, varchar and text.
Thanks for your help.