I have a requirement to upload a document to server, since it is a personal one, they want it to be uploaded outside public folder. I know how to upload a file:
Yes Yii can send file output, but you still have to create your own action.
Lets assume following code in siteController Specific to image output, You can use same way to output other files.
public function actionImage($image_path) {
Yii::$app->getResponse()->sendFile(Yii::getAlias('@image_uploads') . $image_path);
}
now image src will be something like
<img src="/site/image?image_path=/posts/1.png" />
or equivalent to the real application url routes
So basic function to send file output by Yii2 is
Yii::$app->getResponse()->sendFile();
Located Under
\yii\web\Response.php