Forum Moderators: coopster
$filename = "the name of my file";
$filePath = "/path/to/download/$filename";
//lets read this file to the user
//open the file for binary reading
$file = fopen($filePath,"rb");
// we build some headers
header("Content-type: application/octet-stream");
header("Content-Disposition: inline; filename=\"$filename\"");
header("Content-length: ".(string)(filesize($filePath)));
while(!feof($file) )// if we haven't got to the End Of File
{
print(fread($file, 1024*8) );//read 8k from the file and send to the user
flush();//force the previous line to send its info
if (connection_status()!=0)//check the connection, if it has ended...
{
fclose($file);//close the file
die();//kill the script
}
}
fclose($file);//close the file
//if we get this far, the file was completely downloaded
//update the database