A File Download Counter
Sometimes you would really like to know how many people
actually use the download link you provide. Today's article provides
a way to get that information.
It's a PHP script. Link to a PHP script instead of to the
downloadable file.
The script logs the click. Then, the script sends a web page
to the browser that starts the download. That web page can
be edited with a "be patient" message, a poem, ads, link
back to the main page, whatever you like.
The log records the date and time and some other
information. There is one line per download. To see how many
downloads there have been, see how many lines are in the log
file.
Here is the code for the PHP script:
Two places need to be edited, both clearly marked with
instructions in the source code. One is where you specify
the location of the log file and the other is where you
specify the URL of the downloadable file.
The web page source code below the PHP code may be edited as you wish. Just
put
<?php echo($URLofDownloadableFile) ?>
wherever you want the download URL to print.
See how many people are using your
download link.
Note: If you prefer to have a download counter
without requiring an intervening page,
where the download starts right after the click on the download link,
there is one in the WebSite's Secret membership area. It is called
Simple Download Counter with Reporting (membership required)
Question:
Did you find this article interesting and understandable? How can it be improved?
Your response is anonymous.
When done typing, click anywhere outside the box. [more info]
Will Bontrager
© Bontrager Connection, LLC
Please note:
Articles on this website are presented "as is". However -
If you have a question about a CGI script, HTML, CSS, PHP, or JavaScript
Ask one of our Experts and you'll have your answer!
Click here for details.