View Full Version : Download count

03-01-2012, 02:06 PM

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 :)

03-01-2012, 02:23 PM
What type of files are they?

03-01-2012, 02:29 PM
What type of files are they?

They are .SLT files.. A 3D model type..

03-01-2012, 04:19 PM
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).

03-01-2012, 05:07 PM
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.

03-01-2012, 05:16 PM
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!