【发布时间】:2011-01-28 07:24:20
【问题描述】:
我有一些代码可以向图像添加一些标题:
title-background.png.php 的内容:
<?php
$im = imagecreatefrompng("title-background.png");
header('Cache-Control: public');
header('Content-type: image/png');
header('Expires: 19 Febuary 2012 20:00:00 GMT');
imagepng($im);
imagedestroy($im);
?>
而且效果很好。但是当我尝试对另一个文件做同样的事情时,
button.png.php 的内容:
<?php
$im1 = imagecreatefrompng("button.png");
header('Cache-Control: public');
header('Content-type: image/png');
header('Expires: 19 Febuary 2012 20:00:00 GMT');
imagepng($im1);
imagedestroy($im1);
?>
服务器返回 500。 我无权访问我的日志。
【问题讨论】:
-
你检查图像的路径了吗?您有权访问该文件吗?
-
尝试将这些行添加到文件的开头以防止 500 错误,然后查看是否收到 php 错误:
<?php error_reporting(E_ALL); ini_set('display_errors', 'on'); echo "aaa"; ob_flush(); ?>
标签: php image http-headers