【发布时间】:2014-10-08 14:59:21
【问题描述】:
我在我的控制器中生成一个图像(我使用 Symfony2),当我用我的图像返回我的响应时,我得到这个:
HTTP/1.0 200 OK
Cache-Control: no-cache
Content-Disposition: inline; filename=""
Content-Type: image/jpeg
我需要在我的视图中显示图像,但如果我放:
<img src="<?= $response ?>" />
浏览器显示 404 错误,如果我使用
<?php echo $response; ?>
我只会得到
HTTP/1.0 200 OK
Cache-Control: no-cache
Content-Disposition: inline; filename="example.jpg"
Content-Type: image/jpeg
Date: Wed, 08 Oct 2014 14:55:24 GMT
X-Sendfile: 67902
我想展示图片,有什么想法吗?
谢谢!
【问题讨论】:
-
<img src=...需要一个 URL。如果$response包含图像的原始二进制数据,那么您不能只将其填充到 src 属性中。除非你把它变成一个 data-uri。 -
谢谢 Marc,但我怎样才能将这个射线二进制数据转换为 data-uri?
标签: php html image symfony http-headers