I've tried the following force download script and for the life of me I can't get it to download the file. I get the download dialog pop-up, but the file size is only around 500 bytes. I think it is the pathing. I've tried absolute and relative paths for readfile and filesize. The thumbnail page and download.php file are in the photos folder. The file(s) I want to download are images, IMG1.jpg, IMG2.jpg, etc. So, the link users click to download is: download.php?filename=IMG1.jpg.
Your help is much appreciated.
$filename = $_GET['filename']; $path = $_SERVER['DOCUMENT_ROOT']."/photos/lrg/"; #$path = "lrg/"; $fullpath = $path.$filename; if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off'); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-Type: image/jpg"); header("Content-Disposition: attachment; filename=\"".$filename."\";" ); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($fullpath)); readfile($fullpath); exit;