I have a table in my db that stores the files that have been uploaded to my system, and the get_file function returns and object with that information, so to download the file, have code that follows:
if(isset($id) && ($file = get_file($id))) {
header("Content-Type: $file->type");
header("Content-Length: $file->size");
header("Content-Disposition: attachment; filename=$file->name");
header("Content-Transfer-Encoding: binary");
$fh = fopen("$CFG->filelocker/$file->name", "r");
fpassthru($fh);
exit;
} else {
$refer = get_referer();
redirect(url_add_param($referer, "message=Unable+to+get+file."));
}
If you've beared with me this long, you may see where I'm going. When I click on a link that access this page, it starts the download without going to another page first, so if you have a script similar ot this, you should be able to post a DB update before sending the file data.