Skip to content

Instantly share code, notes, and snippets.

@SohanChy
Created July 28, 2015 16:35
Show Gist options
  • Save SohanChy/40239be3a82107d651b2 to your computer and use it in GitHub Desktop.
Save SohanChy/40239be3a82107d651b2 to your computer and use it in GitHub Desktop.
Try to show a PDF instead of download.
<?php
$file = './path/to/the.pdf';
$filename = 'Custom file name for the.pdf'; /* Note: Always use .pdf at the end. */
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);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment