-2
wanted to know how I could recover an image from the database, used the php7, the image is recorded in the database in type BLOB, I searched on the internet and were very old examples and none worked here, someone could help me ?
-2
wanted to know how I could recover an image from the database, used the php7, the image is recorded in the database in type BLOB, I searched on the internet and were very old examples and none worked here, someone could help me ?
0
To insert the image do the following:
$db = mysqli_connect("localhost","root","","DbName"); //keep your db name
$image = addslashes(file_get_contents($_FILES['images']['tmp_name']));
$query = "INSERT INTO products (id,image) VALUES('','$image')";
$qry = mysqli_query($db, $query);
To access the Blob image
$db = mysqli_connect("localhost","root","","DbName"); //keep your db name
$sql = "SELECT * FROM products WHERE id = $id";
$sth = $db->query($sql);
$result=mysqli_fetch_array($sth);
echo '<img src="data:image/jpeg;base64,'.base64_encode( $result['image'] ).'"/>';
I hope it works for you!
Browser other questions tagged php mysql phpmyadmin mysql-workbench
You are not signed in. Login or sign up in order to post.
Just like that.
– Fabio William Conceição
I’ll test it here, and bring the feedback to you.
– Lucas Lima
Thank you very much guy gave it right !
– Lucas Lima