0

我必须在带有“image/jpeg”标题的文件中进行多个输出。

我要显示的第一个文件是图像,然后我的脚本执行其他处理功能,最后我想在同一周期中输出另一个图像。

请看下面的代码:

<?php
header("content-type: image/jpeg");
readfile(realpath("mypath/default.jpg")); // this output my first image directly
// many other functions 
echo $myotherimage->getImageBlob(); // I want that the echo of this variable REPLACE the current outbut buffer ( the readfile )
?>

有什么办法可以做到这一点?我尝试过使用 ob_* PHP 函数,但它不起作用。

4

1 回答 1

0

你不能这样做。

当你设置headercontent-type: image/jpeg意味着告诉浏览器

我将向您发送图像数据作为流

请注意,它是一个图像而不是 很多图像。

如果要显示图像,则应使用HTML <img>标签。

<img src="path/to/image-one"/>
<img src="path/to/image-two"/>
于 2018-04-27T12:42:52.550 回答