Answer the question
In order to leave comments, you need to log in
How to save an image using AssetsManager?
There is this action
public function actionLoad($rest, $ext)
{
$response = Yii::$app->getResponse();
$response->headers->set('Content-Type', 'image/' . $ext);
$response->format = Response::FORMAT_RAW;
$response->data = file_get_contents('http://example.com/' . $rest . '.' . $ext, true);
return $response->send();
}
Answer the question
In order to leave comments, you need to log in
in short, so
$file = Yii::$app->cache->getOrSet($rest . '.' . $ext, function () use ($rest, $ext){
return file_get_contents('http://example.com/' . $rest . '.' . $ext, true);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question