<?php
namespace Engine\Mvc\Response; class FileView extends FileDownload { private $filetype = NULL; public function setFiletype($filetype) { $this->filetype = $filetype; } public function getHeadersFinal() { $headers = parent::getHeadersFinal(); $filetype = $this->filetype; if (!$filetype) { $filetype = \Engine\File::getExtension($this->filename); } $headers->append('Content-Disposition', sprintf('inline; filename="%s";', $this->filename)); switch (strtolower($filetype)) { case 'pdf': $headers->append("Content-Type", "application/pdf"); break; case 'html': $headers->append("Content-Type", "text/html"); break; case 'mhtml': $headers->append("Content-Type", "message/rfc822"); break; case 'xml': $headers->append("Content-Type", "text/xml"); break; case 'gif': $headers->append("Content-Type", "image/gif"); break; case 'jpg': case 'jpeg': $headers->append("Content-Type", "image/jpeg"); break; case 'png': $headers->append("Content-Type", "image/png"); break; case 'webp': $headers->append("Content-Type", "image/webp"); break; case 'bmp': $headers->append("Content-Type", "image/bmp"); break; case 'svg': $headers->append("Content-Type", "image/svg+xml"); break; default: $headers->append("Content-Type", "application/octet-stream"); } return $headers; } protected function generateDownloadHeaders() { } } 