View Full Version : Secured image but save image as works

08-31-2011, 06:57 PM

I am trying to secure some images, so you have to login before being able to view them, I have this working, so I have this

$path = '/home/sitename/downloads/';

if (is_file($path . $_GET['f'])) {
$f = $path . $_GET['f'];
} else {
$f = $path . 'not_found.jpg';

header('Content-type: image/jpeg');
$im = @ImageCreateFromJPEG ($f) or // Read JPEG Image

This output the image to the page, which is a good start but I need it so the right click and 'Save image as' to work, it works but the filename is the name of the PHP file, so images.php for example and I need it to be the so that if the URL is


it should ask me to save ml.jpg

Any pointers are really appreciated.