Thanks for your feed-back. I have followed your idea and after some search on google, I did what is following :
1. create a document directory on the server
2. inside this document directory, add an .htaccess file with these settings :
order deny,allow
allow from 127.0.0.1
deny from all
These settings should disable access to the directory except for the localhost. Thus PHP should only have access.
3. put a test.pdf file inside the document directory
4. create the following php file to access test.pdf
<?php
$file = "test/test.pdf";
header('Content-type: application/pdf');
header("Content-Disposition: inline; filename=".$file);
/*header("Content-Disposition: attachment; filename=".$file);*/
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header('Pragma: anytextexeptno-cache', true);
header('Cache-control: private');
header('Expires: 0');
readfile($file);
?>
The code displays test.pdf inside your browser. If you want to "download" this file, use this line
header("Content-Disposition: attachment; filename=".$file);
instead of
header("Content-Disposition: inline; filename=".$file);
Now I still have to create some authenfication using php but I think that the concept is good.
Also, It should be useful to enforce the code to only display pdf files and not all kind of files, but It should not be a big deal.
hope it can help (even it is not perfect)