コード例 #1
0
ファイル: Files.php プロジェクト: ctlr/Simple-File-Manager
 public function response_view($id)
 {
     $file = static::load($id);
     $name = $file->name;
     $path = $file->getPath();
     $type = isset($file->type) && $file->type ? $file->type : MimeType::mime($name);
     if (file_exists($path)) {
         header('Content-type: ' . $type);
         header('Pragma: public');
         header('Cache-Control: private');
         header("Content-Disposition: inline; filename={$name}");
         header('Content-Description: PHP Generated Data');
         header('Content-Length: ' . filesize($path));
         readfile($path);
     } else {
         echo '<h1>File not found</h1>';
     }
     exit;
 }