I'm making my own website and from the website you can download some of my c++ games. on the website i have this code that writes in to a .txt file some info from the visiter like: ip, os , browser and what site did he/she visit.
so ok i have the c++ game rars on my server and i have a simple html link to them which allow you to download them.
so my problem is, is there a way to check if the user downloads one of these rars? I mean is there a way to check if the user presses one of these download links?

here's the link that i currently use:

 <a href="Memory Game source code.rar" TITLE="Download Memory Game">Download</a>

so is there a way to check using php if that link was pressed?

Recommended Answers

Try putting a PHP link in the href that sends the request to a PHP file that will process the request and sends back the .RAR file.

eg. <a href="download.php?id=546" title="Download Memory Game">Download</a>

Then inside download.php you put code that sends back the .RAR file by specifying the appropriate …

Jump to Post

All 3 Replies

Try putting a PHP link in the href that sends the request to a PHP file that will process the request and sends back the .RAR file.

eg. <a href="download.php?id=546" title="Download Memory Game">Download</a>

Then inside download.php you put code that sends back the .RAR file by specifying the appropriate headers.
e.g. by using a code along the lines below:

$id = $_GET['id'];
//Get the rar file with id equal to $id
//Then pass the rar name into the function below
function forceDownload($file_name){
    header('Content-Type: application/force-download');
    header('Content-Disposition: attachment; filename="'.basename($file_name).'"');
    readfile($file_name);
}

thanks wilch, i will try that out!

thanks again wilch it worked!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.