You are here: File Download Counter « PHP Programming Language « IT news, forums, messages
File Download Counter

Posted by Marius III on 10/30/05 02:53

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($path)) {
$file = fopen($counter_dir."/".$filename.".txt", "r+");
$count = fread($file, 100);
fclose($file);

$count++;

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


$size = filesize($path);

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


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

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

Thanks alot!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация