Answer the question
In order to leave comments, you need to log in
How to save file from server in Yii2?
Hello. There is a link called "Upload to dbf". It leads to the controller that generates the dbf file and puts it in the archive. The archive appears on the server in the web folder. How to download it now? Is there a way to get the link back?
I tried something like this, nothing happened:
ps. I am new to yii. return Yii::getAlias('@app/web/'.$this->file_zip);
Answer the question
In order to leave comments, you need to log in
Alternatively
https://habr.com/ru/post/151795/
Here is another method for Yii2
<?php
public function actionDownload() {
$path = \Yii::getAlias('@uploads') ;
$file = $path . '/some-file.pdf';
if (file_exists($file)) {
return \Yii::$app->response->sendFile($file);
}
throw new \Exception('File not found');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question