简体   繁体   English

如何将资源转换为字符串(Nette)

[英]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.

相关问题 如何在Nette中配置外键? - How to configure foreign keys in Nette? Nette NEON 格式有什么用(与 JSON 相比) - How is Nette NEON format useful (comparing to JSON) 如何从Nette的neon文件中获取值? - How to get values from neon file in Nette? 在Nette PHP框架中不使用模板就返回字符串 - Return string without using a template in Nette PHP framework 如何在框架 Nette 中使用标准的、正常的非漂亮 url 路由? - How to use standard , normal non pretty urls routing in framework Nette? NETTE框架中如何以及在何处包含CSS和JS文件? - How and where to include CSS and JS file in NETTE framework? 如何,是否可以在 Nette 的 Latte 模板中转义并使用原始 php? - How to , is it possible to escape into and use raw php in Latte templates in Nette? 如何使用Nette Tester测试演示者提交的成功表单的响应 - How to test response of successful form submit in presenter test with nette tester Laravel - 如何将 API 资源递归转换为数组? - Laravel - How to convert API Resource to array recursively? 如何从 di 依赖注入容器上下文在 nette 中自动装配/自动装配服务 - How to autowire / autowiring services in nette from the di dependency injection container context
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM