[英]How convert resource into string (Nette)
I have image in PostgreSQL. 我在PostgreSQL中有图片。 I saved it as bytea
(escaped by pg_escape_bytea
). 我将其保存为bytea
(由pg_escape_bytea
逃逸了)。 But I cannot get unescaped
data for sending to browser: 但是我无法获取未unescaped
数据以发送到浏览器:
pg_unescape_bytea() expects parameter 1 to be string, resource given pg_unescape_bytea()期望参数1为字符串,给定资源
$image = $this->imgRepos->getRecord($id);
$rawimage = pg_unescape_bytea($image->picture);
$rawimage = pg_unescape_bytea(base64_encode($image->picture));
有没有base 64编码的解决方案,它允许您按原样读取图像,但是它需要读取文件-我不确定它将采用二进制图像:
$rawimage = pg_unescape_bytea(file_get_contents($image->picture));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.