Created
September 20, 2023 11:32
-
-
Save vielhuber/7d03a136a492fd338bedb3f44475e501 to your computer and use it in GitHub Desktop.
stream output pdf directly to browser #php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$file_abspath = '/foo/bar/baz.pdf'; | |
$file_pseudoname = 'bazzz.pdf'; | |
$content = file_get_contents($file_abspath); | |
header('Content-Type: application/pdf'); | |
header('Content-Disposition: inline; filename="' . $file_pseudoname . '"'); | |
header('Content-Length: ' . strlen($file_abspath)); | |
header('Cache-Control: private, max-age=0, must-revalidate'); | |
header('Content-Transfer-Encoding: binary'); | |
header('Accept-Ranges: bytes'); | |
die($file_abspath); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment