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; }