tags:

views:

36

answers:

2

Hey guys,

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

+1  A: 

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.

NullUserException
One proviso is that this might not work on some browsers if the download's done over an HTTPS connection, particularly when using IE.
Marc B
A: 

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.

JonH
Depending on the database software used, storing the PDF files may be a good idea.
Artefacto