Reputation: 1535
I want to display an Image with a PHP-Script. I get the image data out of a Database. The data is a byte[]. Does anyone know how to do this?
I tried this yet:
function GetImage($imageDataArray)
{
$base64String = "";
for($i = 0; $i < count($imageDataArray); $i++)
{
$string = trim(strtr(base64_encode($imageDataArray[$i]), '+/', '-_'), '=');
$base64String .= $string;
}
return 'data:image/png;base64,' . $base64String ;
}
And call it here:
echo '<img src="'.$im->GetImage($imageDataArray).'" alt="Picture" />';
But I don't get an result. The picture is not shown.
Upvotes: 1
Views: 441
Reputation: 695
get rid of base64_encode() && use urlencode() || rawurlencode()
Upvotes: 0