This is the structure of my mysql table crij_personne :
- id
- photo longblob
- image_name varchar(64)
My html code is the following:
<input type="file" name="photo" />
The code for uploading the image to my database:
$imagetmp=addslashes (file_get_contents($_FILES['photo'] ['tmp_name']));
$image_name = addslashes($_FILES['photo']['image_name']);
$imagetmp= base64_encode($imagetmp);
$sql = "INSERT INTO crij_personne (description, photo, image_name) VALUES ('".$_POST['description']."','$imagetmp',' $image_name');";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
The code for displaying the image on a web page is:
echo '<img height="300" width="300" src="data:image;base64, '.$row['photo'].'">';
But nothing is happening... I'm doing something wrong, obviously. Thanks for the help.