/** * @param Application $app * @param $filePath * @param bool $download * @param string $media */ public function fileResponse(Application $app, $filePath, $download = true, $media = "") { if (!file_exists($filePath)) { $app->getErrorManager()->addMessage("Error Occurred: File could not be found to make a proper response."); return; } $content = file_get_contents($filePath); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); if ($download) { header("Content-Type: application/force-download"); header("Content-Type: application/download"); header('Content-Disposition: attachment; filename=' . basename($filePath)); } if ($media == "") { header("Content-Type: application/octet-stream"); } else { header("Content-Type: " . $media); } header("Content-Transfer-Encoding: binary"); echo $content; return; }