Display backend/web/uploads image to frontend in yii2


I am new to yii2 framework and i’m developing website using this framework, I stuck at one point since 2 days to display image from backend/web/uploads folder to frontend/view/site/index.php.

I have already uploaded the images to database using backend in ../uploads folder but now I want to display it to frontend.

I am trying to use AssetBundles ,$basePath,$baseURL, $sourcePath nothing is been working for me.

Could you please explain step by step to get this rid off?

Thanks for your help in advance!


If these are not secret data, better upload images files to frontend/web/img on begining.

Code in conttroler backend


       Url::to('@frontend/web/images/') . $file_name . '.' . $model->file->extension


Hey pceuropa,

Thanks for your suggestion, its working fine now. I have uploaded the backend images into frontend uploads/ folder and saved its path into database.I can see those images to frontend now. :) :)

Used below code :

$model->file->saveAs(’../../frontend/web/uploads/’ .$imageName. ‘.’ .$model->file->extension);

		$model->front_img='uploads/' .$imageName. '.' .$model->file->extension; 

After a lot of struggle I could do it.

Thank you so much!