Can't display local file

See all posts See thread Reply

Re: Can't display local file new!
by colin, 14 years, 2 months ago
I think your server has a problem when sending headers.

Here are my headers when outputing an image:
HTTP/1.1 200 OK
Date: Wed, 03 Mar 2010 20:44:10 GMT
Server: Apache......
X-Powered-By: PHP/5.......
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: image/png


As you can see, my Content-Type is image/png when yours is text/html. In fact, if I output the image without sending the headers, I have text/html too. So it looks to me like your PHP may not be outputing the headers properly.

Besides, it is very possible that you output something else than the image (and its headers) before. If, in your script, you echo some text for instance before outputing the image, then you will have the message The image “...” cannot be displayed, because it contains errors..

So I recommend you try with a very simple script to output an image. Check that you don't have anything (HTML...) before the PHP opening tag in your script, and that your script doesn't output anything before the image headers.

Here is the code I use to try it out:
$img = new Upload('test.png');
$img->image_resize = true;
$img->image_ratio_y = true;
$img->image_x = 400;
header('Content-type: ' . $img->file_src_mime);
echo $img->Process();
die();

With this code, you should see image/png in the HTTP headers, and then your image should display. If not, it may be a problem with your PHP installation, or your Apache server. Try it on another setup to make sure that your code works, or doesn't.Reply
Re: Can't display local file new!
by Kim, 14 years, 2 months ago
Hello Colin,

Thank you so much for your help and for creating this class. Turns out the the problem was a PICNIC! Problem In Chair Not In Computer.

Following your advice I tracked the problem down to two blank lines at the end of my defines file.

Thanks Again
Kim CarrReply