problem showing pictures stored outside web root folder
- by David
On a website users can upload pictures. For security reasons these are stored outside the webroot (public_html) folder. When I need to display the picture, I send the headers and have "readfile" read and output the picture data, like so:
header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-type: image/jpg');
header('Content-Length: ' . $filesize);
readfile($path_url . '/' . $photo);
This works great, but the site is growing and this is starting to be a burden on the server.
Question: is there a way to send the picture or picture data to the user, without the server first having to load the picture (obviously with the picture still being stored outside the webroot folder)?
Thanks!
David