Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I am having some problems sending image files to the browser from php. I am opening a file from the folder and sending it to the browser in the following way:Code: Select all
$tag = fopen('myfile.jpg', 'rb');
if ($tag) {
header('Content-Type: image/jpeg');
fpassthru($tag);
}This code only returns the first four bytes of the image e.g. ÿØÿà .
After opening the image with a hex editor, I noticed that the next character, after the first four bytes is null. So it seems that the null character is wrongly interpreted by either php or web server as end of file, thereby truncating the image file.
The example works on my home machine, but for some reason fails on the hosting server. I am guessing it is probably a bug in web server or php version (4.3.11) they are running on the server (I'm trying to get them to look into it ).
any ideas/suggestions would be useful
thanks
Reks
hawleyjr | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]