public function getAction() { \Auth::check(); if (!($fid = intval($_GET['id']))) { $errors[] = "Не задан id файла"; } try { $file = new File($fid); if ($file->userId != $_SESSION['uid']) { $errors[] = "Файл не найден"; } else { $filePath = FILE_STORAGE_PATH . $this->getHashedFileName($file); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); // нужен для некоторых браузеров header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=\"" . $file->name . "\";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . filesize($filePath)); readfile("{$filePath}"); exit; } } catch (\Exception\ModelNotLoad $e) { $errors[] = "Файл не найден"; } catch (\Exception $e) { $errors[] = "Ошибка загрузки файла"; } $this->show('files', $this->getVarsArray($errors)); }