Serving css images with PHP from an external public folder

I have a css file that refers to images.

.test{
  background: url(http://site.com/dynamic/test.jpg) no-repeat;
}

However, these images are dynamic. They change every minute, so I have to generate and maintain them using php. This means that I do not save them in a shared folder. I just serve them directly from a php script.

The problem is that when I visit php script ( http://site.com/dynamic/test.jpg), it creates the image correctly and I see it in the browser, but when the same URL is used in the css file as I need, css cannot access the images.

I think this is because the image is not saved in the shared folder and delivered to php, which means that the image must be called directly to generate it, and the css file call didn’t actually get into the php script (image URL).

Does anyone have any ideas to solve this problem?

+5
source share
2 answers

Try returning Content-type using php header function

header("Content-type: application/force-download"); 
header('Content-Type: application/octet-stream'); 
header('Content-Type: image/jpeg'); // or png...
+1
source

First of all, you should ask your own system what is happening, not people who have no idea and do not have access to your site.

HTTP, , HTTP- . LiveHTTPHeader firebug Firefox - .

, , .
, .

-2

All Articles