Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Download count

  1. #1
    New Coder
    Join Date
    Feb 2012
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Download count

    Hello

    I need to be able to count the number of downloads on different files on my site. Im currently counting views simply by incrementing a counter on each visit. But i have no idea where to count download since its just a simple <a> link to the file.

    Any suggestions?

    Thanks in advance

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    What type of files are they?

  • #3
    New Coder
    Join Date
    Feb 2012
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    What type of files are they?
    They are .SLT files.. A 3D model type..

  • #4
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Instead of pointing straight to the file, point to a PHP (or w/e server side you're using) file that increases the download count, then forwards to the actual file. You can hash the filename of the download to avoid people going there directly.

    Making a htaccess point all download file requests to a controller is another good way to do it (more or less the above, but more direct).

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Adding to Keleth ...
    You can keep track of counts using a MySQL database, or a simple method
    of updating a count file ... either way, done with PHP. There might be a limit
    issue, depending on how large those .slt files are (byte size). If security isn't
    an issue (you don't care if the users know where the files are located), that
    would make the whole process much easier. Hiding the URL adds some complexity.

  • #6
    New Coder
    Join Date
    Feb 2012
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks to both of you. Security is no problem here. I will try making the link point to another PHP file which counts and then redirects to the download.

    Thanks a lot!


  •  

    Posting Permissions

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