Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- public function fetchFile() {
- if(!Globals::$user) {
- die('You can not download files if you are not logged in.');
- }
- $file->path = "../_private/1/Pragmatic.Textmate.Power.Editing.for.the.Mac.Feb.2007.pdf";
- $file->name = basename($file->path);
- if(file_exists($file->path)) {
- header('Content-Type: application/octet-stream');
- header("Content-Disposition: attachment; filename=\"{$file->name}\"");
- header("Content-Length: " .(string)(filesize($file->path)) );
- readfile($file->path);
- }
- }
Add Comment
Please, Sign In to add comment