Forum Moderators: coopster
I am having a problem with fread (or any other method) displaying an image on a Windows system (not my choice).
My script basically gets an image name from the db, reads it and displays it. I am using this to obscure the real name of the image and give it a new image name. The script works on my development box but doesn't on the production box... it only outputs garbage (like you would open an image in notepad).
I have checked and double checked usual culprits (magic quotes, etc.). The same version of PHP is on the dev and prod boxes.
here is my code:
if(!is_null($image) && file_exists($image))
{
$contents = '';
$size = getimagesize($image);
$handle = fopen($image, "rb");
while (!feof($handle)) {
$contents .= fread($handle, 1024);
}
fclose($handle);
$extension = strtolower(substr(strrchr($image, "."), 1));
}
header("Cache-Control: public");
header ("Content-type: image/jpg");
header("Content-Disposition: inline; filename=\"". $_GET['part'] . "\"");
header('Content-Length: ' . filesize($image));
print $contents;
BTW, $size here was just to check to see if the image functions worked, and they do. However, imagejpeg gives me the same output as the code above.
Any Suggestions?
Thanks
header("Content-Disposition: inline; filename=\"". $_GET['part'] . ".jpg\"");
Added Otherwise, I would recommend looking at the return headers from your development box and your production box and seeing what is different.
Thanks for your help, but I found it myself. Isn't that the way that it usually is, start talking and you figure it out?
The problem was that I was including a class file. At the end of the class file, I had a closing "?>", but also an extra line (carriage return). This file was different from the on on my dev box. By doing this, I was sending a header before the headers in my code. There was no error because the errors were turned off.
Here is the url:
<snip>
Thanks again,
Don
[edited by: eelixduppy at 7:45 pm (utc) on Oct. 3, 2007]
[edit reason] no urls, please [/edit]