How to create file download counter?

雨燕双飞 提交于 2020-01-06 08:51:23

问题


Which is the most simple way to create code ( with PHP and SQL ) which will count the file downloads ?

I already have an integer column in the base dedicated for this feature...

( link to some example will also be welcomed )


回答1:


Create an sql table with two columns:

  1. Full path to file (primary key)
  2. Counter

Setup your links for downloading to go to a php script. In that script, lookup the appropriate table row based on the full path, increment it's count, then redirect the browser to the file for downloading.




回答2:


You can make a download script, which is very bad for performance. My solution would be just periodical apache access log parsing.




回答3:


http://tutorialzine.com/2010/02/php-mysql-download-counter/

(2nd on google search results with keywords: php mysql create download counter)



来源:https://stackoverflow.com/questions/2997482/how-to-create-file-download-counter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!