Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    7

    Question Unanswered: Turn link to ZIPfile into PHP script that logs the download

    I have a page that contains a link to a ZIP-file.

    I want to monitor the downloading of the file. Instead of delving into the weblog, I want to write a timestamp to a file.

    I can change HREF=myfile.zip into HREF=logmyfile.php
    and let logmyfile.php write the timestamp to a text file.

    However, how can I tell PHP that the zipfile should be send to the user after the log has been appended, resulting in the display of the dialogue box that gives the user the choice to Open the file or to Save it to disk?

  2. #2
    Join Date
    Jun 2003
    Location
    Minnesota
    Posts
    61
    logmyfile.php?zip=zip.zip:

    Code:
    <?php
    
    // Open text file, add timestamp, save, and close text file
    
    header("Location: $zip");
    ?>
    Is that what you mean?
    Mr. Lars

  3. #3
    Join Date
    Mar 2004
    Posts
    7
    I am flabbergasted by the simplicity of your suggestion.
    Will give it a try. For sure I must look at the documentation of the possibilities of the header function. I was aware that it could be used to store cookies, and that header() doesn't work if any output already has been sent. Obviously, it's capable of much more.
    Thanks for your suggestion.

    Originally posted by lslars31
    logmyfile.php?zip=zip.zip:

    Code:
    <?php
    
    // Open text file, add timestamp, save, and close text file
    
    header("Location: $zip");
    ?>
    Is that what you mean?

  4. #4
    Join Date
    Jun 2003
    Location
    Minnesota
    Posts
    61
    ...

    header("Location: $link");

    ...will redirect the user to "$link" you could also just put in a url like "http://www.link.com".
    Mr. Lars

Posting Permissions

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