示例#1
0
 protected function downloadFile($id)
 {
     $record = $this->filesModel->get($id);
     if ($record) {
         $fileName = $this->filesModel->getStoragePath() . $record->id;
         if (file_exists($fileName)) {
             $response = new \Nette\Application\Responses\FileResponse($fileName, $record->original, $record->mime);
             $this->sendResponse($response);
             return true;
         }
     }
     return false;
 }
示例#2
0
 public function renderId($id)
 {
     $record = $this->model->get($id);
     if ($record) {
         $this->template->data = $record;
         $this->template->exists = $this->model->exists($id);
         $this->template->location = $this->model->getStoragePath() . $id;
     } else {
         $this->flashMessage("Neexistuje záznam o takovém souboru.", "danger");
         $this->redirect("default");
     }
 }