DZone ForumsDZone Forums  

Go Back   DZone Forums > Community > Languages & Frameworks > PHP
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
LinkBack Thread Tools Display Modes

Topic: force download
Old 04-09-2008, 12:43 AM   #1 (permalink)
Member
 
Join Date: Apr 2008
Posts: 1
I've tried the force download script from your article (PHP Force Download - Keep Up With What's Going Down | PHP Zone) 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 file are in the photos folder. The file(s) are images, IMG1.jpg, IMG2.jpg, etc. So, the link users click is like download.php?filename=IMG1.jpg.

Your help is much appreciated.

##code
$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;
spiderling is offline   Reply /w Quote -


Thread Tools
Display Modes



All times are GMT -5. The time now is 12:47 PM.