在存储在webroot外部的浏览器中打开PDF

I have some PDF's that are only accessible to members only (they have to log in to get them). I'd like to have them show up in the browser, instead a dialog box is showing up asking to save/open the file. The PDF's are stored outside of the regular root directory. Here's the code:

$filepath='/var/www/vhosts/Reports/';
$filename='CA.pdf';
header('Content-Disposition:inline; filename="'.$filename.'"');
header('Content-type:application/octet-stream');
header('Pragma:no-cache');
header('Expires:0');
if ($file=fopen($filepath.$filename,'r')) {
fpassthru($file);
fclose($file);

I read that setting the disposition to inline should fix it, but no good. Any ideas?

I tried to just comment on your post but I am a noob to overflow. I just wanted to share some google search results. Have you tried @readfile?

Show a PDF files in users browser via PHP/Perl

open PDF in browser with PHP

http://php.net/manual/en/function.readfile.php

Hope it helps!

The content type should be 'application/pdf', a browser will recognise this as a pdf and open it as such.