Reply to Re: How to calculate how many downloads?

Your name:

Reply:


Posted by Kimmo Laine on 09/02/05 18:49

"Ben Xia" <ben@jetcom.com> kirjoitti
viestissδ:05_Re.10522$884.867453@news20.bellglobal.com...
> Hello all:
>
> I want to know how many successful downloads from website, is there some
> PHP script can do this?
>
> Let's say I have file "abc.zip" people can download, The system is
> Apache+linux+php+mysql, how I can know exact how many successfully
> downloads and the download time.
>
> I know it can be done by weblog statistic, but I want to know is there
> some way in php can do it so I can save in database and view real time
> result.
>
> any help will be appreciate.
>


Make a file called download.php:
<?php
if(file_exists($file=$_REQUEST['file'])) {
header("Content-type: application/force-download");
header("Content-Length: ".filesize($file));
header("Content-Disposition: attachment; filename=$file");
readfile($file);
file_put_contents('counter.log', file_get_contents('counter.log')+1);
} else {
header("HTTP/1.0 404 Not Found");
}
?>

And make a downloadlink <a href="download.php?file=abc.zip">download</a>

Although this counts only attempted downloads, not succesful ones.

--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>
Kimmo Laine eternal.erectionN0@5P4Mgmail.com

[Back to original 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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация