Hi Guys
I am pulling my hair out on this one. I have some really simple code, that outputs images with php. This code works on my localhost (and about 10 other friends I have asked to check). It even worked with my online host until they upgraded the version of Apache from 1.3 (I think) to 2.2.3.
The weird thing is it only seems to fail on some images, other it works fine with.
Some searching brought up the possibility that EnableSendfile and EnableMMap need to be set to off to fix the problem.
I requested the change from my host, who say they have made it, but the streaming code still doesnt work on some images.
Firstly, is there anyway I can check they have turned the options off (phpinfo doesn't seem to show it).
Secondly, is there anything else that anyone thinks might be the problem.
Here is the code:
<?php
function streamGif($file) {
if (is_file($file)) {
while(ob_get_level()) {ob_end_clean();}
header('Content-Type: image/gif'); //tell the browser its a gif
header('Content-Length: '.filesize($file)); //tell the browser how big
header('Last-Modified: '.date('D, d M Y H:i:s', filemtime($file)).' GMT'); //last modified, so it can be cached correctly
echo file_get_contents($file); //output the binary of the file
exit;
} else {
print($file.' is not file?');
}
}
streamGif('controlpanel_toprepeat.gif');
?>
Obviously that image is one of the ones breaking. If I use certain different images, they work fine.
Thanks in advance!