Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: Need scripts that lists how many times file downloaded

  1. #11
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,035
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Are you sure you mean bbcode? Bbcode is a special markup used to format text in forum posts.

    More info here http://en.m.wikipedia.org/wiki/BBCode

    Please provide more information about how/where you'd be using a flat file counter script and maybe we can assist.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  2. #12
    Join Date
    Dec 2008
    Location
    Selby, North Yorkshire
    Posts
    90
    Thanks
    28
    Thanked 2 Times in 2 Posts

    Default

    Hi Bev, would you clarify something for me?

    I've got this script working fine as you can see here;
    http://www.castlefordheritagetrust.org.uk/zSandPit.php

    However what is the purpose of this line;
    $download = 'http://mywebsite.com/file/to/download.zip'; // the link to your download file

    I've taken it out and it still works, the php is

    <?php

    $counter = 'php/counter.txt'; // text file to store download count - create manually and put a 0 (zero) in it to begin the count
    $number = file_get_contents($counter); // read count file
    $number++; // increment count by 1
    $fh = fopen($counter, 'w'); // open count file for writing
    fwrite($fh, $number); // write new count to count file
    fclose($fh); // close count file
    header("Location: $download"); // get download

    ?>

    Cheers

    John

  3. #13
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,035
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    $download is the variable which stores the downloadable file (ie the zip file in my example), so that at the end of the script, after all the count logging is done, the file is downloaded. The header() functions in the last line summons the download.

    In my earlier example I have pointed a download link to a php file that contains this code instead of directly to the downloadable file. An alternative use as you have discovered, is that you can instead paste the code directly into a web page and use it as a hit counter (with the $download line and header line both removed as they would be redundant)
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  4. The Following User Says Thank You to Beverleyh For This Useful Post:

    BorderTerroir (04-07-2015)

  5. #14
    Join Date
    Dec 2008
    Location
    Selby, North Yorkshire
    Posts
    90
    Thanks
    28
    Thanked 2 Times in 2 Posts

    Default

    Excellent, thanks for that.

    All I need now is the Trust newsletter

  6. #15
    Join Date
    Oct 2016
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Red face

    Just wondering if this page was still alive? I have a similar need for the code please check:
    http://wavapps.net/bin/bin.htm ... I have had some luck with the second one but with a different code. What would work for me in these pages without changing them to .php instead of htm? I would like for the number of downloads to display above the picture where it says Downloads. http://wavapps.net/wismec.htm

    Thanks in advance...
    Last edited by jscheuer1; 10-28-2016 at 01:02 PM. Reason: format

  7. #16
    Join Date
    Oct 2016
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post

  8. #17
    Join Date
    Oct 2016
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I do not understand with it all broke up like that. I need to see altogether. but I am studying it. Thank you though;-)

  9. #18
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,035
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    For reference, here is the updated complete PHP code plus download pack. http://www.dynamicdrive.com/forums/e...)-AJAX-amp-PHP

    However, this will not work for a .htm/.html page unless your server is setup to parse PHP in HTML pages.

    You couldn't really provide a counter on the client-side in JavaScript alone because the counts could only be saved on each viewing computer (using cookies or localStorage) - they'd be different for each computer looking at the page. You would need a server-side language such as PHP in order to stores counts on the server and make them accessible by anyone viewing the web page.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  10. #19
    Join Date
    Oct 2016
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I think that is a little closer to what i am looking to do. It seems that you are showing me a way to do all the counting of lets say the 146 logos with the use of only 3 files. A lot to digest and I think I am starting to get it...


    Thanks a great deal

  11. #20
    Join Date
    Mar 2017
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up How to place this code to (display result only) in .htm file instead of .php?

    Quote Originally Posted by Beverleyh View Post
    1 - Put the following code into a file called "counter.php";
    PHP Code:
    <?php

    $counter 
    'path/to/counter.txt'// text file to store download count - create manually and put a 0 (zero) in it to begin the count
    $download 'http://mywebsite.com/file/to/download.zip'// the link to your download file

    $number file_get_contents($counter); // read count file
    $number++; // increment count by 1
    $fh fopen($counter'w'); // open count file for writing
    fwrite($fh$number); // write new count to count file
    fclose($fh); // close count file
    header("Location: $download"); // get download
      
    ?>
    2 - Create the text file defined in the $counter value/location above and just put a 0 (zero) in it. The sample code file is called "counter.txt".

    3 - Create a download link to the "counter.php" file instead of the actual download file;
    Code:
    <a href="path/to/counter.php">DOWNLOAD</a>
    4 - To display the download count on your web page;
    PHP Code:
    <?php echo file_get_contents('path/to/counter.txt');?>
    Hope that helps
    Here,

    Thank You, Beverleyh.

    Step 1,2,3 worked for me but Step no.4 didn't gave me result.
    Because i was having my page where result was to shown was html page not php page.
    So I want the code of Step 4 in html format!

    Can this be done? If possible how?

    Waiting for reply, Thank You again...

Similar Threads

  1. torrent file scripts
    By willy108 in forum PHP
    Replies: 4
    Last Post: 09-25-2007, 08:03 AM
  2. many scripts in one file
    By marringi in forum Other
    Replies: 0
    Last Post: 06-20-2007, 04:42 PM
  3. 2 Scripts on same html file.
    By Antonisid in forum Dynamic Drive scripts help
    Replies: 5
    Last Post: 04-26-2007, 07:30 PM
  4. Replies: 1
    Last Post: 08-20-2005, 10:44 AM
  5. How can I prevent a file from being downloaded?
    By inyiss in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 03-08-2005, 03:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •