Guest User

Untitled

a guest
Jul 12th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. <?php
  2. public function fetchFile() {
  3. if(!Globals::$user) {
  4. die('You can not download files if you are not logged in.');
  5. }
  6.  
  7. $file->path = "../_private/1/Pragmatic.Textmate.Power.Editing.for.the.Mac.Feb.2007.pdf";
  8. $file->name = basename($file->path);
  9.  
  10. if(file_exists($file->path)) {
  11. header('Content-Type: application/octet-stream');
  12. header("Content-Disposition: attachment; filename=\"{$file->name}\"");
  13. header("Content-Length: " .(string)(filesize($file->path)) );
  14. readfile($file->path);
  15. }
  16. }
Add Comment
Please, Sign In to add comment