Tutorial :Best way to go about storing/accessing PDF Files


Just a quick question (maybe not)

I'm looking to add to my website a way for a customer to login and once logged in they are able to select their invoices which i will upload to my server.

My question is what is the best way to go about storing the files and accessing them. i've done some googling and haven't been able to find much in the way of pointing me in the right direction.

Thanks in advance


Upload them to an unaccessible directory (outside of the www root or protected by htaccess) and serve them with PHP.

This can be done like so:

$file = '/path/to/yourpdf.pdf';    header('Content-type: application/pdf');  header('Content-Length: ' . filesize($file));  readfile($file);  

Use PHP and SQL to determine what $file should be and whether or not the user has permission to view the file.


One recommendation I have is to ensure you do not store the actual file in the db. Make sure all you are storing is a pointer (the hyperlink) to a file that is stored somewhere on your network.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »