PHP making a download counter without leaving the current page

前端 未结 4 1349
刺人心
刺人心 2020-12-11 11:31

I tried to create a download counter with PHP. The script, I have created, works, but when I click the download link, the script sends me to a blank page. Is it possible to

4条回答
  •  死守一世寂寞
    2020-12-11 12:06

    Ok as you have most of the code missing here is an example, basically your need to call the counter code inside the download.php file, and pass through the file contents after doing the counter code and setting download headers. also be wary or allowing malicious people to download any file from your server by just passing the file name to the download function. download.php?file=index.php ect

    
    
    
    
    
    
    
    
    
    
    exampleA.zip (Downloaded  times)
    exampleB.zip (Downloaded times)

    download.php as you can see it outputs no HTML as this would corrupt the file.

    
    

    Make sure you check the $downloads_folder variable is correct. Hope it helps.

    Download Full example code.

提交回复
热议问题