Advertisement
Guest User

Display a pdf without revealing the path

a guest
Oct 30th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.48 KB | None | 0 0
  1. <?php
  2. $file = "reports/".urldecode($_REQUEST['dir'])."/".urldecode($_REQUEST['rep']);
  3. $len = filesize($file);
  4. header("Cache-Control: no-store, maxage=1, must-revalidate"); // HTTP/1.1
  5. header("Cache-Control: post-check=0, pre-check=0", false);
  6. header("Pragma: public"); // HTTP/1.0
  7. header("Content-type: application/pdf");
  8. header("Content-Length: $len");
  9. header("Content-Disposition: inline; filename=file1.pdf");
  10. header("Content-Transfer-Encoding: binary\n");
  11. readfile($file);
  12. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement