yii2 Advanced Project Template Sharing uploaded files between the frontend and backend using symlinks


Example

So you've uploaded your files to a folder say /backend/web/uploads/ and you want these uploads to be visible on the frontend too. The easiest option is to create a symlink in the frontend that links to the backend:

ln -s /path/to/backend/web/uploads/ /path/to/frontend/web/uploads

In your views you can use relative links to the files now:

<img src='/uploads/<?= $model->image?>' alt='My Image goes here'>
<a href='/uploads/<?= $model->filename?>' target='_blank'>Download File</a>

Ensure that your webserver allows symlinks to be followed.