Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7646051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:06:25+00:00 2026-05-31T10:06:25+00:00

Is there a way we can create a dynamic download link in PHP for

  • 0

Is there a way we can create a dynamic download link in PHP for a single file for some period of time or the download link expires after that time. After that period the download link changes.

Actually I have a requirement where the download link should be accessible only through a particular email. I can’t add that file as an attachment because of its size.

Can any one help me in this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:06:26+00:00Added an answer on May 31, 2026 at 10:06 am

    One solution:

    1. Create a Database table which stores a large unique ID (random), and the name/location/content of the file to download. Also include an expire date.

      id                    | filename           | expires
      ----------------------+--------------------+--------------------
      fsdhfs7dfsniuf92un3f2 | secret.doc         | 2012-03-23 23:32:32
      sdf8shdf829nf32ufn23f | secret2.doc        | 2012-03-13 23:32:33
      
    2. Email a link to your end user… The link should be something like:

      http://yoursie.com/download/fsdhfs7dfsniuf92un3f2
      
    3. Use an apache rewrite rule (mod_rewrite) which will capture the nice looking link and pass it to a PHP page:

      RewriteEngine on
      RewriteRule ^/download/([a-z0-9]{20})$  /download.php?id=$1
      
    4. In that script, download.php, look at $_GET['id']. Run a database query to look up the record. Check the expiration date. If all is OK, then proceed.

    5. Either use the PHP script to output the correct headers and download the file, or send an internal redirect to a front-end proxy like nginx, which will offload the download process to nginx and not tie up PHP with the download.

    Either way, you have a secure, expireable link that you can send to your end users.

    Take care!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out if there is some way to create a dynamic
Is there a way I can create Windows firewall exceptions in VB2005? I'm trying
In SQL Server 2005, is there a way I can create a INSERT script
Is there a way that I can create a function that takes an int
Is there any way that I can create a new delegate type based on
I wish to know is there any way that I can create the threads
Is there any way that I can programmatically create (and I guess access) hidden
If I create an application on my Mac, is there any way I can
Is there a way to programmatically create a compressed folder in Windows? I can't
We can't use java.text.SimpleDateFormat, so is there any way to create date object from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.