PHP4 mime headers and CSS background-image

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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

<img src='resource.php?name=thejpegfile.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?name=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?


Re: PHP4 mime headers and CSS background-image

Littlefire wrote:
Quoted text here. Click to load it

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.php?name=thejpegfile.jpg");


Site Timeline