PHP images returning 500 internal server error?
I have some code that adds some headers to an image:
Contents of title-background.png.php:
<开发者_Python百科?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);
?>
And that's working fine. But when I tried to do the same with another file,
Contents of 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);
?>
The server returns with 500. I have no access to my logs.
I suspect that button.png
doesn't exist, can't be read, or is somehow incompatible with imagecreatefrompng()
.
Wow, Sorry guys - cluttering up the stackoverflow server. Withing 1mins over my breakfast I worked it out...
the title-background.png.php was pointed to from a .css fie ON THE SAME SERVER :- however, the button.png.php was from a DIFFERENT SERVER!
I have now fixed it by putting the full paths, including http://'s and the such.
精彩评论