5 Replies - 18790 Views - Last Post: 13 December 2012 - 09:49 PM

#1 angelo dundee  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 29-June 05

How do I count downloads from my website ?

Posted 09 August 2005 - 08:40 AM

I have some simple programs on my web site, for download :-
www.engineeringspreadsheets.co.uk, see Sling Design Program

When a user presses the link ' Free Demo Version' to download a program, how can I provide some sort of counter, which tells me how many times the program has been downloaded ?

:rolleyes: :blink:

Is This A Good Question/Topic? 0
  • +

Replies To: How do I count downloads from my website ?

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: How do I count downloads from my website ?

Posted 09 August 2005 - 08:56 AM

What scripting language are you using? You can increment a counter in a database everytime someone downloads, or write the updated number to a file.
Was This Post Helpful? 1

#3 lattyware  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 56
  • Joined: 08-August 05

Re: How do I count downloads from my website ?

Posted 09 August 2005 - 10:21 AM

Some very simple PHP would be the best option here.

<?php
$Down=$_GET['Down'];
?>

<html>
<head>
<meta http-equiv="refresh" content="0;url=<?php echo $Down; ?>">
</head>
<body>

<?php

$fp = fopen("Count.txt", "r");
$count = fread($fp, 1024);
fclose($fp);
$count = $count + 1;

//Un-comment to display the downloads.
echo "Downloads:" . $count . "";

$fp = fopen("Count.txt", "w");
fwrite($fp, $count);
fclose($fp);

?> 

</body>
</html>




Call it download.php and then put a link to 'download.php?Down=download.zip'
Simple enough, and the number of donwloads will be stored in a text file.

I have made a version to try out here: http://www.lattyware.co.uk/Test/
The download is a zipped set of the files.

This post has been edited by lattyware: 09 August 2005 - 10:22 AM

Was This Post Helpful? 2

#4 angelo dundee  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 29-June 05

Re: How do I count downloads from my website ?

Posted 23 August 2005 - 11:23 AM

My website package supports :-
Java
Perl 5.0
Private CGI-bin
PHP 4.1.2.
Was This Post Helpful? 1
  • +
  • -

#5 spacebar22  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 13-December 12

Re: How do I count downloads from my website ?

Posted 13 December 2012 - 09:16 PM

Hi

Trying not to ask you do to my homework for me... This post was very useful (it works fine). What would be the best approach to extend this to multiple downloads per page? Ideally with only one Count.txt, but separate lines in that file for each download.Or separate count files would be fine too. Is there a good php function where I can specify the file name and then the action required for that name?
Was This Post Helpful? 0
  • +
  • -

#6 gregwhitworth  Icon User is offline

  • Tired.
  • member icon

Reputation: 219
  • View blog
  • Posts: 1,604
  • Joined: 20-January 09

Re: How do I count downloads from my website ?

Posted 13 December 2012 - 09:49 PM

You could build an array for file names and their counts, and since you said that this is homework I'll let you start, post your code if you run into a problem.

This post has been edited by gregwhitworth: 13 December 2012 - 09:50 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1