Hello. Faced a problem in yii2, I can’t properly configure nginx to upload files via xSendFile. Link in the office. Documentation is not working. Maybe there is some kind of article or configuration example. I could not figure it out myself.
1 answer
https://github.com/yiisoft/yii2/blob/495553616dc41b9a5db141931388d9502d19eb13/docs/guide-ru/runtime-responses.md# file- https: //github.com/yiisoft/jp/jp/jp/jp/php/flp/gun/runtime-responses.md# send files web / Response.php # L691
Something like this:
class SiteController extends Controller { public function actionIndex() { return Yii::$app->getResponse()->xSendFile(__DIR__ . '/SiteController.php'); } } - Perhaps not so explained. I found the syntax in yii2 itself. I do not understand how to configure nginx. Although now I am even more confused: you specified the path to the controller file as the file path, is this just for example? - Andrey
- This is a working example. I have a standard nginx without any additional settings. The SiteController.php file cannot be downloaded under normal nginx settings, so I chose it as an example. I downloaded the file from a closed directory with the original name. - LAV45
- Unfortunately, this example doesn’t work correctly for me, the file weighing 0 is downloaded. It is written in the docks to yii that this is due to the incorrect nginx configuration. But thanks for the reply. - Andrey
|