SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    header('Content-Type: image/jpeg'); not behaving as I hoped it would.

    When I run a script that contains the following code:

    Code:
    header('Content-Type: image/jpeg');
    readfile("$IMAGES_FILE_PATH/oldman.jpg");
    I think that my browser should be showing the image that's being referenced (whose contents are, in fact, being read correctly), but instead, it displays the URL of the script that was just run.

    I'm currently using MAMP (Version 1.7.2 - default installation) and running Leopard (10.5.7) on a MacBook. My PHP information can be found at jiggzy.com/phpinfo.

    Could anyone shed some light on the issue of why DreamHost is displaying the image properly, but not my local version of PHP? Thanks in advance for any help!

  2. #2
    SitePoint Zealot adam.jimenez's Avatar
    Join Date
    May 2009
    Location
    Ware, UK
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the header looks fine to me.

    are you sure the image contents are being read correctly?

    trying commenting out the header to see if any errors occur.

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You probably have output something other than the binary image data(don't do that). For example, some whitespace, or html.

    Your browser might still let you right click > view source so you can look.

  4. #4
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whenever I run this code:
    Code:
    <?php
    require_once('scripts/vars.php');
    header('Content-Type: image/jpeg');
    echo readfile("$IMAGES_FILE_PATH/cafe.jpg");
    ?>
    I get the following output (|s used to break up URL because the forum won't allow me post any links):
    Code:
    http | 127.0.0.1 | 8000 | Jiggzy%20Quick-Start%20Package | imagetest | php
    Then, whenever I run this code:
    Code:
    <?php
    require_once('scripts/vars.php');
    echo "File Path: $IMAGES_FILE_PATH/cafe.jpg<br />";
    echo readfile("$IMAGES_FILE_PATH/cafe.jpg");
    ?>
    I get this output:
    Code:
    File Path: /Users/nickcherry/Desktop/Web/Jiggzy Quick-Start Package/images/cafe.jpg
    �JFIF��H�H��Exif��MM�*���������������������������������������(�������1����)���2������<������>������)?������9�������i������l��Canon�Canon EOS DIGITAL REBEL XTi����'���'Adobe Photoshop Elements 4.0.1 Macintosh�2008:07:03 19:27:29�Mac OS X 10.5.3���9����I�����@���d���!���d������d���G���d������d������d����������������"�������'���� �������0220������������Α������������
    ...And so it goes...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •