Results 1 to 6 of 6

Thread: Download Hit Counter?

  1. #1
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Download Hit Counter?

    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.

  2. #2
    Join Date
    Jan 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Here's something to try

    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

    strFile=request..querystring(“file”)

    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

    strFile=request..querystring(“file”)

    ‘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

    rs("counter")=cint(rs("counter"))+1

    rs.Update

    rs.Close

    Set rs=nothing

    conexion.Close

    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!

  3. #3
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks princess. I'll try out what that article says to do.

  4. #4
    Join Date
    Jan 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  5. #5
    Join Date
    Dec 2004
    Posts
    177
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default

    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.

  6. #6
    Join Date
    Aug 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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)
    Last edited by thetestingsite; 08-19-2007 at 10:57 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •