insert into the database after downloading an file
I am providing the users to download a file. I wants to have user log for downloading the file.
I want that if an user really download the file then it should enter in the database. Below is the code i am using.
When an user clicks on an file name , it prompts an download window with as usual two options download and cancel. What i would like to have is that when someone really downloads the file then it should insert in the database.
$file = strip_tags($_GET['q']);
// Quick check to verify that the file exists
if( !file_exists($file) ) die("File not found");
// Force the download
header("Content-Disposition: attachment; filename=\"" . basename($file) . "\"");
header("Content-Length: " . filesize($file));
//INSERT INTO DATABASE
Currently when someone clicks on the file it saves in the database instantly insead of actual download.