469,950 Members | 2,369 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

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-------------------
$download_dir = "download";
$counter_dir = "counters";
$filename = $_GET['filename'];

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

if (file_exists($path)) {
$file = fopen($counter_dir."/".$filename.".txt", "r+");
$count = fread($file, 100);


$file = fopen($counter_dir."/".$filename.".txt", "w");
fwrite($file, $count);
$size = filesize($path);

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

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

Thanks alot!
Oct 30 '05 #1
0 1470

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Bernhard | last post: by
7 posts views Thread by mistral | last post: by
4 posts views Thread by pradqdo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.