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

  • Home
  • SEARCH
  • 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 8024205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:47:53+00:00 2026-06-04T22:47:53+00:00

I have this in my code: <a href = res/pdf/sample.pdf>Sample PDF</a> So basically it

  • 0

I have this in my code:

<a href = "res/pdf/sample.pdf">Sample PDF</a>

So basically it will appear to be a download link to file ‘sample.pdf’ but the problem is, there’s a restriction in downloading this file. so whenever there are confidential reports uploaded and a malicious user accidentally memorized or viewed the URL of the download link in the browser history he can easily download it even without accessing the website because it is a direct link. What am i supposed to do so this link will be protected? or be downloaded only for the user assigned to it?

  • 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-06-04T22:47:54+00:00Added an answer on June 4, 2026 at 10:47 pm

    Don’t serve up files by their direct URLs. Have a PHP script receive the filename of the file wanted, and serve it up.

    So, if someone wants to download the above files, he would go to

    example.com/getfile?file=sample.pdf

    Your PHP script would check if the current user has permission to view the file, and then serve it up.

    Make your links like this:

    <a href = "http://example.com/getfile?file=sample.pdf">Sample PDF</a>
    

    Your current method is very insecure for sensitive files. A malicious user could trivially write a script to download ALL files in res/pdf. All he needs to do is check every permutation of letters in the directory, and throw away all 404 errors.

    You will not redirect the user since that would defeat the purpose. You will serve the file as a download with the appropriate Content-disposition header.

    Here’s an example: Fastest Way to Serve a File Using PHP

    You can google and get many more examples.

    Here’s a great example that shows how to serve PDF files:
    https://serverfault.com/questions/316814/php-serve-a-file-for-download-without-providing-the-direct-link

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

Sidebar

Related Questions

i have this code: $('.access a').toggle(function() { $('link').attr('href', 'styles/accessstyles.css'); $('body').css('font-size', '16px'); }, function() {
I have this code : <a class=myLink href='http://www.website.it/'>Link</a> <script type=text/javascript> var stringToSend = ;
I have this code in my page: <a href onClick=return false;>Press me!</a> The link
I have this code: var fullpath = $(this)[0].src; var a = document.createElement('a'); a.href =
so I have this code for tabs in jquery, the href is set to
HI, I have this code for extracting the href and adding it to a
I have this code, which works: $('.invest-port-thumb a').mouseenter(function() { $('#slider-name').load(this.href + ' cName'); });
I have this code but is not working and I don't know why... function
I have this code that creates links. /* Create a link to activate the
I have this code: $('.be-delete').live('click', function(e){ e.preventDefault(); var object =$(this); var url = $(this).attr('href');

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.