Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 图像输出无法正常工作_Php - Fatal编程技术网

Php 图像输出无法正常工作

Php 图像输出无法正常工作,php,Php,我在上课时有一种奇怪的行为。 该类调整图像的大小并将其输出。有关守则如下: // output the image header("Content-Disposition: filename={$output};"); header("Content-Type: {$info["mime"]}"); header('Content-Transfer-Encoding: binary'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', ti

我在上课时有一种奇怪的行为。 该类调整图像的大小并将其输出。有关守则如下:

// output the image
header("Content-Disposition: filename={$output};");
header("Content-Type: {$info["mime"]}");
header('Content-Transfer-Encoding: binary');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');

readfile($output);
 <img style="-webkit-user-select: none" src="http://localhost/tv-tracker/images/media/2/backdrop-100x100.jpg">
结果就是这个奇怪的小正方形:

和HTML格式如下:

// output the image
header("Content-Disposition: filename={$output};");
header("Content-Type: {$info["mime"]}");
header('Content-Transfer-Encoding: binary');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');

readfile($output);
 <img style="-webkit-user-select: none" src="http://localhost/tv-tracker/images/media/2/backdrop-100x100.jpg">

任何帮助都将不胜感激

误用
,嵌套使用出现问题,只需更改给定标题的内容类型即可

header("Content-Type: {$info["mime"]}");

例如:

$output = 'http://placehold.it/350x150';
header("Content-Disposition: filename={$output};");
header("Content-Type: image/jpeg");
header('Content-Transfer-Encoding: binary');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');

readfile($output);

标题(“内容类型:{$info[“mime”]}”);
我怀疑错误报告和来自服务器的响应表明存在语法错误。不要只查看网页上的“图像”,查看实际的服务器响应。对此进行了更改,但仍然不起作用。我在readfile()之前添加了obclean(),但它不起作用(如图所示)作为我的示例,我成功地实现了这一点,但我只发现了一个错误。您也可以检查我给出的示例,可能是您的服务器出现了一些问题。。