PDA

Click to See Complete Forum and Search --> : Need a file download counter to my Home Page


Michel Jr
Aug 15th, 2000, 06:37 AM
Hi,

I would like to add a counter at my Home Page to know how many times a file was downloaded.
How to do this or where can I find it?

Thanks a lot...

Michel Jr.

Mark Sreeves
Aug 15th, 2000, 08:03 AM
I may be wrong but I think some ISPs provide this service.

Alternatively you could write an Active Server Page which logs each time the file is downloaded

Mark Sreeves
Aug 15th, 2000, 05:02 PM
OK i've just knocked this up. It needs polishing up a bit.

database dload.mdb has a table called table1 with two fields in it
Filename and count
count is Number data type.


<%@ Language=VBScript %>

<!--
Written by Mark Sreeves
-->
<BODY>
<%

dim Fname
dim conn
dim rst

Fname = request("Filename")
if Fname <> "" then
'open the connection to the database
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\dload.mdb")


strSQL = "Update Table1 set count = count+1 where filename='" & Fname & "';"
conn.execute strsql

response.write "<SCRIPT LANGUAGE='JavaScript'>" & vbcrlf

response.write "window.location='" & Fname & "';" & vbcrlf

response.write "</SCRIPT>"

end if
%>

<form name="frm1"action="download.asp">
<A HREF="javascript:document.frm1.submit()">Download Myfile.zip</A>
<input name="Filename" type="hidden" value="Myfile.zip">
</form>



</BODY>
</HTML>