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);
}
[b]Force Downloading[/b]
Moderator: General Moderators
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
You pass it a variable to show that the file is in a different directory?
Code: Select all
ForceFileDownload('../../rahh.zip', '');