[b]Force Downloading[/b]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thunder44
Forum Newbie
Posts: 1
Joined: Mon Nov 01, 2004 8:32 am

[b]Force Downloading[/b]

Post 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);
}
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

You pass it a variable to show that the file is in a different directory?

Code: Select all

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