This topic is locked

Open a PDF stored on the server

11/30/2011 10:44:13 PM
PHPRunner General questions
C
cjsaputo author

All I want to do is place a button on a screen which, when clicked, opens a PDF. The file is the user documentation.

C
cgphp 12/1/2011

Showing a PDF file is possible only if a PDF plugin is installed in the browser, otherwise, it will always be served as a download file.

$file = '/path/to/filename.pdf';

$filename = 'filename.pdf';
header('Content-type: application/pdf');

header('Content-Disposition: inline; filename="' . $filename . '"');

header('Content-Transfer-Encoding: binary');

header('Content-Length: ' . filesize($file));

header('Accept-Ranges: bytes');
@readfile($file);