Jump to content

How do I display PDFs stored outside of web root.


andrew2704

Recommended Posts

I understand that if I want to keep uploaded files secure I need to save them outside of the web root. I have managed to do that. The question is, how do I display those files in a browser window? Usually I would use header() to display but I don't know how to do that with files outside of the web root.

 

Any suggestions in terms of how best to upload, secure and then display PDFs without exposing them to other users other than the one accessing them.

 

One forum suggested making a temporary copy for the browser to access. Firstly I don't know how to do that and secondly, surely while the temporary file is there it is exposed to other users?

 

Your help would be much appreciated!

 

 

 

Thanks for pointing me in the right direction.

 

I am not sure that I understand the process - how readfile and header work together. I am assuming my code will look something like this:

 

<?php

header('Content-type: application/pdf');

readfile('original.pdf');

?>

 

How do header and readfile interact?

Thanks for the help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.