'downloads' => $downloads, 'download' => $download ]); } public function actionDownload($id){ $model = File::find()->where(['id'=>$id])->one(); $fileLocation = \Yii::getAlias('@webroot').'/../uploads/download_' . $model->id; header('Content-type: application/octet-stream'); header('Content-Length: ' . filesize($fileLocation)); header('Content-disposition: attachment; filename="'.$model->filename.'"'); readfile($fileLocation); exit(0); } public function actionImpressum(){
} public function actionDownload($id){ $model = File::find()->where(['id'=>$id])->one(); $fileLocation = \Yii::getAlias('@webroot').'/../uploads/download_' . $model->id; header('Content-type: application/octet-stream'); header('Content-Length: ' . filesize($fileLocation)); header('Content-disposition: attachment; filename="'.$model->filename.'"'); readfile($fileLocation); exit(0);
$args = $this->controller->bindActionParams($this, $params); Yii::trace('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); Yii::$app->controller = $oldController; return $result; } else { $id = $this->getUniqueId(); throw new InvalidRouteException('Unable to resolve the request "' . ($id === '' ? $route : $id . '/' . $route) . '".');
$route = $this->catchAll[0]; $params = array_splice($this->catchAll, 1); } try { Yii::trace("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } else { $response = $this->getResponse(); if ($result !== null) { $response->data = $result;
try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
require(__DIR__ . '/../vendor/autoload.php'); require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); $config = require(__DIR__ . '/../config/web.php'); (new yii\web\Application($config))->run();
$_GET = [ 'r' => 'site/download', 'id' => '8', ]; $_SERVER = [ 'PATH' => '/usr/local/bin:/usr/bin:/bin', 'CONTENT_LENGTH' => '0', 'HTTP_CONNECTION' => 'close', 'SCRIPT_NAME' => '/web/index.php', 'REQUEST_URI' => '/web/index.php?r=site/download&id=8', 'QUERY_STRING' => 'r=site/download&id=8', 'REQUEST_METHOD' => 'GET', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'REMOTE_PORT' => '65535', 'SCRIPT_FILENAME' => '/home/www/public_html/verzeichnis/web/index.php', 'SERVER_ADMIN' => '[no address given]', 'CONTEXT_DOCUMENT_ROOT' => '/home/www/public_html/verzeichnis/', 'CONTEXT_PREFIX' => '', 'REQUEST_SCHEME' => 'http', 'DOCUMENT_ROOT' => '/home/www/public_html/verzeichnis/', 'REMOTE_ADDR' => '54.81.136.84', 'SERVER_PORT' => '80', 'SERVER_ADDR' => '127.255.255.253', 'SERVER_NAME' => 'thoma-bedachungen.de', 'SERVER_SOFTWARE' => 'Apache', 'SERVER_SIGNATURE' => '', 'HTTP_VIA' => '1.1 10.18.66.127:80, 1.1 [fe80::eeb1:d7ff:fe84:9c66%service]:8080', 'HTTP_ACCEPT_CHARSET' => 'utf-8', 'HTTP_ACCEPT' => '*/*', 'HTTP_USER_AGENT' => 'claudebot', 'HTTP_HOST' => 'thoma-bedachungen.de', 'FCGI_ROLE' => 'RESPONDER', 'PHP_SELF' => '/web/index.php', 'REQUEST_TIME_FLOAT' => 1711722819.1050091, 'REQUEST_TIME' => 1711722819, ];