How to create zip file link that expires?

Discussion in 'PHP' started by RickBurns, Dec 21, 2009.

  1. #1
    Hello,

    I'm hosting zip files and I want them to expire after the downloader has had a chance to finish the file. Since the file is stored in a static place what's the best way to do this? Examples?

    Thanks in advance.
     
    RickBurns, Dec 21, 2009 IP
  2. CodedCaffeine

    CodedCaffeine Peon

    Messages:
    130
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Probably the best way to do this is setting up a php page that retrieves the file, but doesn't give it's location away.

    Ex:
    http://site.com/file.php?id=58gfsa7g98f

    The PHP page would check the ID for malicious code, then check the database for the ID. The mysql table would have similar to

    ID, file_id, file_location, file_accessed, date_accessed

    The php page would update in the database that file_accessed = true/1 and the date_accessed, then setup a cron job that checks the database every once 20min - 1 hour and see which files in the database need to be removed. Usually, a timeout on a file would end up to be about 2 hours, so you would remove entries that are date_accessed + 2 hours.

    If you need anymore info, just let me know. :)
     
    CodedCaffeine, Dec 21, 2009 IP
  3. zolwang

    zolwang Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks,i will do like this.
     
    zolwang, Dec 21, 2009 IP
  4. RickBurns

    RickBurns Peon

    Messages:
    185
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks! :)
     
    RickBurns, Dec 22, 2009 IP