Jump to content

Block access to files


jdp407

Recommended Posts

I am setting up a system that requires certain files (pdfs, docxs, etc) to only be able to be viewed if a certain cookie is set.  If I were doing this with a PHP file, I could do it very easily, however as this is not the case, I have no idea how to go about performing this task.  I believe MIME types come in somewhere...

 

For example, if we take this source forge link http://sourceforge.net/projects/jaycalculator/files/Win32/JayCalc 0.2.0.exe/

It appears to be a .exe file, however the web browser is able to display it as a html document.

Link to comment
Share on other sites

That link is NOT a link to the actual file. It is a link to a page where you can download the file. The backslash at the end indicates that the "JayCalc 0.2.0.exe" is a folder name not a file name. They may also be using modrewrite functionality to reformat the url into parameters - but that is not needed for what you want.

 

First off, put the files into a filder that is NOT web accessible. Then simply build a front end to determine the user's level of access to the files. If the user is allowed, provide them a link to a download page - adding a unique identifier for the file. Example:

<a href-"downloadfile.php?fileid=123">Download this file</a>

 

That page should again check the user's permission to the file. Then user server-side code to READ the file and then serve to the user's browser. To see how to do this, just do some searching for force download scripts.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.