Content types for images

Discussion in 'PHP' started by MCJim, Jul 8, 2008.

  1. #1
    I have a script that uses "header('Content-type: image/jpeg');" to show an image. While this is OK for entire web pages that have the content type image/jpeg, it doesn't work when the image is embedded in an html or a php page, such as when in an image link.

    How can I have the content-type only apply to the embedded image link and not the entire page? Thanks in advance.
     
    MCJim, Jul 8, 2008 IP
  2. fsmedia

    fsmedia Prominent Member

    Messages:
    5,163
    Likes Received:
    262
    Best Answers:
    0
    Trophy Points:
    390
    #2
    you need to create a separate file, such as image1.php and then put the header into that file

    then src is like this, <img src="image1.php"> and then it should appear properly.

    Here is the full reference for you: http://us.php.net/gd
     
    fsmedia, Jul 8, 2008 IP
  3. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #3
    and if you have a script that reads userdefined images, you can check the imagetype by using getimagesize (check php.net)
     
    EricBruggema, Jul 12, 2008 IP