View Full Version : Download Hit Counter?

01-09-2005, 06:13 PM
Hi everyone. I was wondering if someone could tell me the code that shows how many times a file has been downloaded. I don't have a clue how thats done. Thanks in advance.

01-09-2005, 11:51 PM
The Article

First, let’s say you want to build a page with a bunch of downloads but DO NOT what the users to
know the exact path where all of your files are stored.

If you use the following link it would totally reveal the path:

<a href=”downloads/winxp/manual.pdf”>

So what you can do in order to hide this information is to build an intermediate asp file that will launch the download without revealing the actual path.

The new link would look like this:

<a href=”downloads.asp?file=manual.pdf”>

Here’s the code to downloads.asp


Option explicit

Dim strFile


response.redirect “downloads/winxp/”&strfFile


When downloads.asp is called, the browser will prompt a window for the user to either open or save the file! This way the path will be hidden from the user and it will remain a secret!

You might also want to keep track of how many times has a file being downloaded.

To do so, you would only need to add that a little code before the respose.redirect


Option explicit

Dim strFile


‘Begins code to update the downloads counter

Set conexion= server.createobject("adodb.connection")

Set rs=server.createobject("adodb.recordset")

strSql="select * from downloads where file='" & strFile &"'"

conexion.open YourStringConnection

rs.open strSql,conexion,1,3




Set rs=nothing


Set conexion=nothing

‘Ends Code to update the downloads counter

response.redirect “downloads/winxp/”&strfFile


By using this example you will manage your downloads in a more professional way!

01-12-2005, 04:50 PM
Thanks princess. I'll try out what that article says to do.

01-17-2005, 06:37 AM
Okay, I've tried this in every way I can think of. Obviously I am doing it wrong. When I create my download link, it tries to download the actual asp file. Also, how would I get the download counter to show? I have multiple downloads per page, can I have them all work out of the same asp and show their own download numbers? Please help, I'm so confused. Thanks.

01-18-2005, 06:54 AM
What princess neglected to mention, is that your host must also allow ASP scripting. Many free and/or cheap hosts do not allow any server-side scripting to be done.

08-19-2007, 10:49 PM
u need server side scripting for that.
u can use ASP, cgi etc for that depending upon yr server.

{Signature Removed By Moderator}
(Please wait until you have 5 or more posts before using a signature)