Binary data stored as resource
- Bill Lions
- Member | 47
I am storing some binary data in a bytea field.
$bin = base64_encode($values->image->getContents());
When I try to retrieve the data, I get a resource id.
How can I get the actual image data, and not the resource?
- Bill Lions
- Member | 47
Solution:
Because PDO returns BYTEA as a resource, and not a string, the above issue is
encountered.
The workaround is in latte template
<img src="data:image/jpeg;base64,{php fpassthru($post->image_content)}" alt="{$post->image_name}" />