So, I've followed a lot of posts here on StackOverflow still can't work out why my code doesn't work.
I want to be able to open a .pdf
file outside the web root, so I've tried this code:
<?php
$file = '/user/Desktop/exemplo.pdf';
echo $file.'<br>';
$filename = 'test.pdf';
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
@readfile($file);
?>
Problem is I always get the same error:
pdf this file cannot be correctly displayed
I've decided to try several browsers: firefox, chrome, opera and finally internet explorer which suprinsingly said something the others didn't:
file does not start with '%pdf-'Local\EWH-696-6
So does someone know what I need to configure in my code to open pdf's? Or to have them start with the code above (hardcoding it didn't fix it).
EDIT: tried removing the echo
and still had the same error.