Answer the question
In order to leave comments, you need to log in
How to access frontend files in backend?
There was a need to save pictures in /frontend/web/uploads/team/
(advanced template).
Now we need to display these pictures backend
in some views
.
I write the output of the image like this:
echo BaseHtml::img('@frontend/web/uploads/team/'. $model->image, ['width' => '150px','height' => '150px']);
/backend/web/
- everything works fine! Yii::setAlias('@imageTeam', '@frontend/web/uploads/team/');
frontend
to backend
?
Answer the question
In order to leave comments, you need to log in
You can do this:
Yii::setAlias('@frontendHost', 'http://example.com');
echo Html::img('@frontendHost/uploads/team/'. $model->image, ['width' => '150px','height' => '150px']);
There are several ways to solve this problem
1. Make a SymLink to /frontend/web/uploads/ in (if you have Linux) to the folder with images
(ln -s path-to /frontend/web/uploads/ path-to/backend/web /uploads/)
2. When uploading images /frontend/web/uploads/ duplicate /backend/web/uploads/
3. Write a PHP class that renders images
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question