Hi there,
I am developing a system that allows users access to a collection of market reports on an individual basis depending on which reports they have purchased. These documents are in HTML format and stored below Apaches dcoument root. I have a script that copies the HTML and another that copies the images. The references to the images are replaced with references to the script thus..
<img src="image.php?report_code=uk010013&file_name=image004.gif" />
I am having trouble with images intermitently not displaying even though they definately exist, pressing refresh will often force them to display correctly. Here is my image code
<?php
ob_start();
$base_dir = "/path/to/image/dir/";
$image_dir = $base_dir . $report_code . "_files/";
$path = $image_dir . $file_name;
if(file_exists($path)) {
clearstatcache();
$stat = stat($path);
header("Content-Type: image/gif");
header("Content-Disposition: inline");
header("Content-length: $stat[7]");
$fp = fopen($path,"r");
while(!feof($fp)) {
$buffer = fread($fp, 4096);
print $buffer;
}
}
ob_end_flush();
?>
Anybody got any idea why my images might not always display correctly or any ideas of a better way to overcome this problem?
Cheers Stew