Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Image Header

    Hi!

    I don't know if this is ok, so can somebody give me some explanation.

    I made some php script to get Header from http request. When I request
    some image header looks like:

    HTTP/1.1 200 OK
    Date: Mon, 11 Aug 2003 17:24:14 GMT
    Server: Apache/1.3.27 (Unix) PHP/4.3.1
    Last-Modified: Fri, 25 Oct 2002 09:37:57 GMT
    ETag: "1cd2ce-1253f-3db910f5"
    Accept-Ranges: bytes
    Content-Length: 75071
    Connection: close
    Content-Type: image/jpeg
    ===========================================

    Then I made some php script to showing images and when i request for
    example img.php?name=somejpg.jpg header looks like this:


    HTTP/1.1 200 OK
    Date: Mon, 11 Aug 2003 17:24:14 GMT
    Server: Apache/1.3.27 (Unix) PHP/4.3.1
    X-Powered-By: PHP/4.3.1
    Connection: close
    Content-Type: text/html
    ===========================================

    Why?. Image showed correctly and here is code I have in img.php


    =================================

    $file = $_GET['name'];

    if (ereg('(\.\.)^(\/+)',$file)) {
    die();
    }

    $file = dirname(__FILE__).'/'.$file;
    $size = getimagesize ($file);
    $fp = fopen($file, "rb");

    if ($size && $fp) {
    header("Content-type: {$size['mime']}");
    fpassthru($fp);
    exit;
    } else {

    }

    So I set Content-type: but on request is html/text. And one more
    question. Is it possible that IE or mozzila cache those kind of
    images. For example that I ser Cache header option..

    --
    tia,
    Uros

    Uros Gruber Guest

  2. Similar Questions and Discussions

    1. How to use image as pannel header?
      hi all, we here here are building a flex application for Laingorourke UK's domestic housing solution, which will cater the dynamic needs of...
    2. Sorting when there's an image in the header doesn't seem to work....
      I've got a datagrid that works just ducky. I then put in the headers image and now my sort event doesn't get fired. If I take out just the...
    3. Image in header column (not replacing column header text)
      I have a sortable (asc/desc) datagrid and would like to add a small arrow icon (down/up) next to the column header text to improve the UI. Is this...
    4. DataGrid with image in the Column Header
      Is it possible to have both an image and text as part of a Column Header in a DataGrid? Ideally, you could click on either sort the column. I have...
    5. Datagrid and header with image
      Iam trying to implement sorting. I know how to display a button in the header of an datagrid. How can i display an image with down arrow and...
  3. #2

    Default Re: [PHP] Image Header

    --- Uros Gruber <uros.gruber@sir-mag.com> wrote:
    > I made some php script to get Header from http request. When I
    > request some image header looks like:
    >
    > HTTP/1.1 200 OK
    > Content-Type: image/jpeg
    >
    > Then I made some php script to showing images and when i
    > request for example img.php?name=somejpg.jpg header looks
    > like this:
    >
    > HTTP/1.1 200 OK
    > Content-Type: text/html
    Your instincts serve you well. You want the Content-Type header to be correct,
    as you are currently telling the Web client that you are sending HTML, and then
    (I assume) dumping a bunch of binary data.
    > Image showed correctly
    On what browser? IE has earned a poor reputation for its disregard for content
    type, so IE's bug may be conveniently counteracting your own by coincidence.
    > here is code I have in img.php
    >
    > $size = getimagesize ($file);
    > header("Content-type: {$size['mime']}");
    OK, I see that the documentation is somewhat confusing here (I may try to fix
    this). The key phrase in the manual preceding this example is:

    "Beginning with PHP 4.3, getimagesize() also returns an additional parameter,
    mime, that corresponds with the MIME type of the image."

    So, before we continue, can you tell us what version of PHP you are using? You
    might want to just do this:

    header('Content-Type: image/jpeg');

    Hope that helps.

    Chris

    =====
    Become a better Web developer with the HTTP Developer's Handbook
    [url]http://httphandbook.org/[/url]
    Chris Shiflett Guest

  4. #3

    Default Re[2]: [PHP] Image Header

    Hello,

    Monday, August 11, 2003, 10:42:58 PM, you wrote:

    CS> --- Uros Gruber <uros.gruber@sir-mag.com> wrote:
    >> I made some php script to get Header from http request. When I
    >> request some image header looks like:
    >> Content-Type: text/html
    CS> Your instincts serve you well. You want the Content-Type header to be correct,
    CS> as you are currently telling the Web client that you are sending HTML, and then
    CS> (I assume) dumping a bunch of binary data.
    >> Image showed correctly
    CS> On what browser? IE has earned a poor reputation for its disregard for content
    CS> type, so IE's bug may be conveniently counteracting your own by coincidence.
    On both mozzila and IE.

    >> here is code I have in img.php
    >>
    >> $size = getimagesize ($file);
    >> header("Content-type: {$size['mime']}");
    CS> OK, I see that the documentation is somewhat confusing here (I may try to fix
    CS> this). The key phrase in the manual preceding this example is:

    CS> "Beginning with PHP 4.3, getimagesize() also returns an additional parameter,
    CS> mime, that corresponds with the MIME type of the image."

    CS> So, before we continue, can you tell us what version of PHP you are using? You
    CS> might want to just do this:

    Server: Apache/1.3.27 (Unix) PHP/4.3.1
    I check that i get correct MIME, so header is OK. Also if i manualy
    set to jpeg, nothing helps.

    CS> header('Content-Type: image/jpeg');

    I think I'm stuck here.

    best regards

    Uros

    Uros Gruber Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139