Page 1 of 1

[b]Force Downloading[/b]

Posted: Mon Nov 01, 2004 8:43 am
by thunder44
The following PHP Codes mentioned below (used to download a file) work only if the file to download is in the same folder as that of the php file. How do you make it work if the file to download is not in the same folder as that of the php file?

function ForceFileDownload($file,$strCoachId)
{
$filesize = @filesize($file);
header("Content-Type: application/octet-stream");
header("Content-Type: application/force-download");
header("Content-Type: application/download");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename= " .$file. ";");
header("Pragma:no-cache");
header("Expires:0");
//@set_time_limit(600);
readfile($file);
}

Posted: Mon Nov 01, 2004 9:03 am
by kettle_drum
You pass it a variable to show that the file is in a different directory?

Code: Select all

ForceFileDownload('../../rahh.zip', '');