PHP Image content type problem

Posted by Mirko on Stack Overflow See other posts from Stack Overflow or by Mirko
Published on 2011-01-05T18:43:50Z Indexed on 2011/01/05 18:53 UTC
Read the original article Hit count: 239

Filed under:
|
|
|

Hi everybody,

I have a specific problem, and cant get over it.

For my latest project I need a simple PHP script that display an image according to its ID sent through URL. Here's the code:

header("Content-type: image/jpeg");
$img = $_GET["img"];
echo  file_get_contents("http://www.somesite.hr/images/$img");

The problem is that the image doesn't show although the browser recognizes it (i can see it in the page title), instead I get the image URL printed out.

It doesn't work neither on a server with remote access allowed nor with one without. Also, nothing is printed or echoed before the header.

I wonder if it is a content type error, or something else. Thanks in advance.

© Stack Overflow or respective owner

Related posts about php

Related posts about header