I have a personal project that’s been online for sometime now. I’ve been keeping a tally of downloads by doing this:
- When the user clicks the download link, it hits a PHP script that writes some information to a table.
- Once the data is written, the script returns the path to the actual file.
- The user then has the ability to save the file to their hard disk as if it was any other download.
This has worked well enough for sometime; however, it prevents users from being able to right-click > save target as... because they’ll actually just see download.php appear in the ‘File Save..’ dialog. Thus, the only way to download the project is to left-click on the link.
I’d like to improve the process so that a user can download the project using whatever method with which s/he is most comfortable. So, what are some better ways to transparently log downloads without getting in the user’s way?
For what it’s worth, the machine is a standard LAMP stack, so no .NET options here.
This is taken from the php-documentation, but is also possible using different script languages:
The HTTP-Header Content-Disposition tells it to save it as a download.
Another option would be to inspect your log-files regularly, like every day using a script.