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 1092631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:42:45+00:00 2026-05-16T23:42:45+00:00

I previously posted here: Controlling Access for Trial Subscription Since this is a new

  • 0

I previously posted here:

Controlling Access for Trial Subscription

Since this is a new question based on suggestions there, I thought I should start a new post. If this should have been an edit, please let me know for the future.

I think the solution I’m going with to control access will be to upload a file and hash the name. The file will be in the format:

/uploads/#############.pdf

A link will be sent to subscribers. The first time they come to the site, they’ll be asked to create a “pin” and a “hint” to remember. Then can then access a landing page to list their items via an email address/pin combo.

My question is: I know I can control the access to the page that shows what items they can view, but is there a way to control the /uploads/[file] to only be download-able after some kind of programmatic check? I can’t think of any way to do this….

Thanks again.
D.

  • 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-16T23:42:46+00:00Added an answer on May 16, 2026 at 11:42 pm

    Your pdf files don’t have to be in a user viewable directory. They can be outside your web root. That way, noone can actually browse to www.yoursite.ext/uploads/2395wrfhgt.pdf to download it himself or share the link with others.

    In order to download the pdf you’ll have a dedicated script that will do all the access checks on the user that’s requesting it, and if all ok it will set the appropriate headers, read the file from the filesystem, and print it out to the user.

    So, lets say your site is at /var/www/site/htdocs/ and you upload every pdf into /var/www/site/uploads/ . You don’t even need to hash the filenames but instead can keep them nicely named for easy organization.

    Then, all the links to download a file will be made to point to www.yoursite.ext/download.php?id={fileid}

    Your download.php will do all the access checks (properly logged in, has permissions to download the file etc), and then do the following:

    $pathToPdf = '/var/www/site/uploads/some.pdf' ;
    
    header('Content-Type: application/pdf');
    header('Content-Length: ' . filesize($pathToPdf));
    header('Content-Disposition: attachment; filename=' . 'some.pdf');
    
    readfile($pathToPdf) ;
    

    And that’s pretty much it. Once you get this working you can look into improving a few things:

    • use mod_rewrite or similar to have the actual pdf filename in the link, which helps some browsers realize they should download it: http://www.yoursite.ext/download/{fileid}.pdf
    • consider using the web server instead of php to serve files, eg X-Sendfile header
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a new understanding of a question I posted previously: I have a
I have posted a question on here previously asking similar advise, but this project
I've seen this question posted here previously but I'm not satisfied that I understand
I have posted similar question previously, but this time I am providing some code
Previously i posted a question in SO , without knowing what caused this error.
sorry for my English. I previously posted this question as: Multiple ViewModels request same
I followed the question previously posted here I need to do pretty much same,
My question is similar to a question previously posted but never really answered here:
This question was previously asked and answered correctly, but there did not seem to
Previously I posted a question regarding multithreading. Actually my intension is to send SMS

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.