Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Thanked 0 Times in 0 Posts

    Random URL That Expires

    I want to hide a file somewhere on my server. I then want to create a random url that will eventually expire(after a few days) which links to this file. Then I want to give this url to my customers in order for them to download the file.

    I tried this tutorial at http://forums.devshed.com/php-develo...url-38357.html This code works fine & is exactly what I'm looking for. The only problem with this code is the location of the secret file is eventually revealed in this line:-
    PHP Code:
    // Take the user to the file: 
    header("Location: http://mydomain.com/filedir/" addslashes($n)); 
    So how do I hide the actual location of the file?


  • #2
    Master Coder
    Join Date
    Jun 2003
    Cottage Grove, Minnesota
    Thanked 1,096 Times in 1,087 Posts
    Not sure how complex you want to make it ...

    No matter how you do it, you'll have to give them a URL to
    download the code ...

    So I would do something like this (using PHP/MySQL ?) ...

    You create a random directory with the file copied into it ...like: /id34324/yourfile.zip
    That would be the key thing. Your PHP script is taking the original file and copying
    it into the new directory, so your original file location is kept secret.

    You give the customer that id number (id34324).
    When they log-in with that id number, they are allowed to download
    the file. After so many days, that directory and file are deleted, but you
    retain their id number in the database ... so if they come back and say
    that the need to download it again (for some reason), you can verify that
    they downloaded it once already and decide what to do ... either put the
    directory and file back in place, or assign a new id.

    But since you might use MySQL anyhow, I think if a file is saved in the
    database (instead of in a directory), you have some control over things.
    I'm not a MySQL expert, but I think there might be some possibilities there.
    Last edited by mlseim; 11-10-2006 at 05:39 PM.

  • #3
    Regular Coder
    Join Date
    Aug 2006
    UK, London, Dartford
    Thanked 14 Times in 14 Posts
    Easyest way to make a DB with all generated links, date and user id. So user can only download it and query the date, if it i dunno 5 days older than in TB set link as expired.


    Posting Permissions

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