File Download Counter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marius III

    File Download Counter

    Hi there,

    I am building a File download counter in PHP5.

    It's working fine but the problem is that its not working with any Download
    Managers for ex: Free Download Manager / DAP etc.
    The download manager downloads the actual PHP script file.

    How can I correct this?
    Here is my code:

    -----------------CODE BEGIN-------------------
    <?php
    $download_dir = "download";
    $counter_dir = "counters";
    $filename = $_GET['filename'];

    $path = $download_dir."/".$filename ;

    if (file_exists($p ath)) {
    $file = fopen($counter_ dir."/".$filename.".t xt", "r+");
    $count = fread($file, 100);
    fclose($file);

    $count++;

    $file = fopen($counter_ dir."/".$filename.".t xt", "w");
    fwrite($file, $count);
    fclose($file);


    $size = filesize($path) ;

    header("Content-type: application/octet-stream");
    header("Content-disposition: attachment; filename=".$fil ename);
    header("Content-length: ".$size);


    readfile($path) ;
    exit();
    }
    ?>

    -----------------CODE END-------------------

    Thanks alot!


Working...