headers for images

A

Anonymous

Guest
I store images in my database, and the return them to to browser using "image.php?id=234" this works fine except for some small problems:

1. When the user wants to save the file, he doesn't get the original filename of the image, how do I send the original filename with the image?

2. I noticed that caching of the images is not really working right now. Probably because the browser thinks that it is an dynamic file, wich can change. But I know for 100% certain that "image.php?id=234" will ALLWAYS be that image.
How do I tell the browser (and proxy's on the way) they can cache the file as long as they want??

I'm currently using the following headers:
Code:
Header("Cache-Control: public");
Header('Content-type: ' . $image['imagetype']);
where $image['imagetype'] is fetched from the database ofcourse.

Greetz Daan
 
from a newsgroup:

to send the filename with the image:
Code:
header("Content-disposition: inline; filename=mypic.png");
additionally, you can send the image size with the image:
Code:
header("Content-lenght: ".filesize("mypic.png"));

Now I still have to find out how to cache the files...

Greetz Daan
 
dvdbinternet said:
from a newsgroup:

to send the filename with the image:
Code:
header("Content-disposition: inline; filename=mypic.png");
additionally, you can send the image size with the image:
Code:
header("Content-lenght: ".filesize("mypic.png"));

Now I still have to find out how to cache the files...

Greetz Daan
Hi!
Try set PRAGMA variable in HTML or set lifetime of session.
 
the PRAGMA variable is (if i'm correct) a html option, I want images to be cached as long as possible by the browser and proxys between the browser and the server.
These images are retrieved from a database using a php-script.

The lifetime of a session has nothing to do with this as far as I know, that is only about when the session can be safely destroyed (because the user isn't there anymore)

Greetz Daan
 
dvdbinternet said:
the PRAGMA variable is (if i'm correct) a html option, I want images to be cached as long as possible by the browser and proxys between the browser and the server.
These images are retrieved from a database using a php-script.

The lifetime of a session has nothing to do with this as far as I know, that is only about when the session can be safely destroyed (because the user isn't there anymore)

Greetz Daan
Why you insert in DB Images?
I hear about simply and faster method store images at server: PHP and MySQL Web Development -- by Luke Welling, Laura Thomson
 
because its much more easy to manage those images inside my site.
also, some images are not to be seen by some images, this way I can prevent that some users can see that images, because I can check that in the image-script.

OK, it can be done with the acces control of apache and stuff like that, but I simply prefer this solution, because it fits better in my way of programming and "security control"

Greetz Daan
 
Back
Top