PHP echo image

Discussion in 'PHP' started by bobby9101, Aug 16, 2007.

  1. #1
    Hi, I am using soehting like: site.com/pic.php?picture=picture.gif
    and on pic.php
    I want to display "picture.gif"
    I can do this using <img src="$_GET['picture']" alt="" />
    But I also want to be able to use an HTML image on another page to be able to view it.

    So on site2.com I want to be able to sue: <img src="ite.com/pic.php?picture=picture.gif" alt="" /> and the picture to be displayed.
    How do I do this?
    It works if I echo out the image source in php using file_get_contents, but if I go to pic.php it shows the source and I want it to show the image
     
    bobby9101, Aug 16, 2007 IP
  2. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You will need to set the correct mime type for your picture in the headers.
     
    matthewrobertbell, Aug 16, 2007 IP
    bobby9101 likes this.
  3. ehlokoen

    ehlokoen Peon

    Messages:
    161
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    on top of everything place

    header("Content-type: image/yourimagetype");
    PHP:
    for example, /png, /jpeg, /gif
     
    ehlokoen, Aug 16, 2007 IP