Image doest show, pls help !

Discussion in 'Programming' started by diggits, Jan 5, 2011.

  1. #1
    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.com/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.
     
    diggits, Jan 5, 2011 IP
  2. Minimal Hank

    Minimal Hank Peon

    Messages:
    136
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Are you sure it's a JPEG file ?

    header("Content-Type: image/jpeg");
    $fileName = $_GET['img'];
    readfile("http://www.example.com/$fileName.jpeg");
    PHP:
    Still no output ?
     
    Minimal Hank, Jan 5, 2011 IP
  3. diggits

    diggits Well-Known Member

    Messages:
    63
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    113
    #3
    Thanx but, that was the first thing Ive tried.

    Doest work here coz of the blocked remote access

    :_(
     
    diggits, Jan 5, 2011 IP
  4. QiSoftware

    QiSoftware Well-Known Member

    Messages:
    805
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    158
    #4
    you are making the image part of the string. concatenate as a variable.

    Q...
     
    QiSoftware, Jan 6, 2011 IP
  5. php.freak

    php.freak Well-Known Member

    Messages:
    185
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #5
    Please check the image type and then do it again......
     
    php.freak, Jan 6, 2011 IP