PHP4 mime headers and CSS background-image

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Littlefire

    PHP4 mime headers and CSS background-image

    Hi all

    I wrote a proxy script that fetches images out of a database and sends the
    data to the browser, using the Content-type header. For instance, if I'm
    loading a jpg image from the database, the script's output will be:

    header("Content-type: image/jpeg");
    header("Content-length: <filesize-goes-here>");
    print $imagedata;

    $imagedata then obviously contains the binary image data that was in a blob
    field in the database.

    All that works surprisingly swell when I call the script with something
    like:

    <img src='resource.p hp?name=thejpeg file.jpg'>

    Now I have a need to use some of these database-archived images in CSS as
    background images. For instance:

    #menu {
    background-image: url(./resource.php?na me=thejpegfile. jpg);
    }

    However, that refuses to work, I'm left without the background image
    although the rest of the page displays fine.

    Any ideas why the db proxy script would work when called from HTML but not
    when called from CSS?

    Thanks,
    :A
  • NC

    #2
    Re: PHP4 mime headers and CSS background-image

    Littlefire wrote:[color=blue]
    >
    > #menu {
    > background-image: url(./resource.php?na me=thejpegfile. jpg);
    > }
    >
    > However, that refuses to work, I'm left without the background image
    > although the rest of the page displays fine.
    >
    > Any ideas why the db proxy script would work when called from
    > HTML but not when called from CSS?[/color]

    It could be a file location issue; resource.php must be in the same
    directory with the style sheet. Assuming this is not the case, you may
    want to get rid of "./", replace a relative URL with an absolute URL,
    and/or enclose the URL in quotes. Try these:

    background-image: url("resource.p hp?name=thejpeg file.jpg");
    background-image:
    url("http://yoursite.com/resource.php?na me=thejpegfile. jpg");

    Cheers,
    NC

    Comment

    Working...