Hello,
I want to store images in htdocs/img
and use CHtml::image to show them.
Yii::getPathOfAlias(‘webroot’) is returning the wrong path.
I tried Yii::getPathOfAlias(‘webroot’) . ‘../img’
but the CHtml::image does not show the image.
Thanks
Hello,
I want to store images in htdocs/img
and use CHtml::image to show them.
Yii::getPathOfAlias(‘webroot’) is returning the wrong path.
I tried Yii::getPathOfAlias(‘webroot’) . ‘../img’
but the CHtml::image does not show the image.
Thanks
Use Yii::app()->request->baseUrl:
Yii::app()->request->baseUrl.'/img/image.png'
Yii::app()->request->baseUrl
This is still returning the path including my app name.
/htdocs/appname/img
I want
/htdocs/img
Thanks
Try such code:
Yii::app()->request->baseUrl.'/../img/image.png'
That works, thank you.