attachment // Attachments: attachment -> content $attachmentkey = \App\Model\Attachmentkey::retrieve($this->database, $key); if (!$attachmentkey) { // No such key $this->FlashMessage('Attachment not found, not accessible or no longer present'); $this->redirect('default'); } $attachmentkey->increasedownloads(); $attachment = \App\Model\Attachment::retrieve($this->database, $attachmentkey->attachment); $contents = $attachment->contents; $contenttype = Nette\Utils\MimeTypeDetector::fromString($contents); header("Content-type: ". $contenttype); header("Content-Disposition: attachment; filename=\"".$attachment->filename."\""); print $attachment->contents; $this->terminate(); } }