I have a problem to download images stored in my Mysql database as a blob. I tried already a lot of solutions which I found in other posts but the result is every time the same:
"[{"image":null},{"image":null},{"image":null}]"
I reduced my code more and more to get the spot as small as possible but nothing. This is my last try which is actually a copy of this post :Empty PHP output from MySQL database for a longblob
<?php
// Create connection
$con=mysqli_connect("Server","User","Pw","DBName");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// This SQL statement selects ALL from the table 'Locations'
$sql = "SELECT CAST(engineerSignature as CHAR(1000000) CHARACTER SET utf8) as engineerSignature FROM tblservreport";
if ($result = mysqli_query($con, $sql)){
$resultArray = array();
$tempArray = array();
// Loop through each row in the result set
while($row = $result->fetch_object())
{
$tempArray = $row;
array_push($resultArray, $tempArray);
}
// Finally, encode the array to JSON and output the results
echo json_encode($resultArray);
}
mysqli_close($con);
?>
but it also didn’t work. Do I look on a wrong place? I’m sure that the images are OK because I have another program on a Windows PC and on that I download it directly without the way through PHP and it works fine. I read a lot of answers about why it’s not a good way to store an image in a DB like this but this is not my choice I have to follow this way.
I hope someone else can see what I am missing or has an idea what I can try.