Advertisement
Guest User

code

a guest
Oct 13th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. Ok so I first check isset for the session to check if the user is logged in, I added inside an a tag href="?pdf" then i run the following php
  2. $fullUrl = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
  3. if (strpos($fullUrl, "pdf") == true){
  4. { $pdf = file_get_contents("www.example.com/pdffolder/example.pdf");
  5. header("Content-type: application/octet-stream");
  6. header("Content-disposition: attachment;filename=example.pdf");
  7. echo $data; }
  8. I then added this htaccess
  9. RewriteEngine On
  10. RewriteBase /
  11. RewriteCond %{REQUEST_FILENAME} ^.+\.pdf$
  12. RewriteRule .* - [F,NS,L]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement