AP81
(Adamperks81)
January 9, 2014, 5:14am
1
Hi,
I currently have some images stored in protected/data/service/. I now need to be able to serve this via the web, so I decided to move them to the <webroot>/images folder.
That solved one problem, but how do I access them in the filesystem? i.e.
i.e. before i could do:
$imageFile = Yii::app()->basePath . Yii::app()->params['IMAGES_SERVICE_DIR_PATH'] . $id . '.jpg';
if (is_file($imageFile)) {
Given that the images are now in <webroot>/images/service, I could probably do something using Yii::getPathOfAlias(‘application’), but I was hoping for a more elegant solution.
Anyone got any ideas?
zmiftah
(Zeinmiftah)
January 9, 2014, 7:57am
2
You could try this one
Yii::getPathOfAlias('webroot.images.service');
hemc
(Hemendra Chaudhary619)
January 9, 2014, 9:36am
3
$imageFile = dirname(Yii::app()->basePath) .DIRECTORY_SEPARATOR."images".DIRECTORY_SEPARATOR. $id . '.jpg';
if (is_file($imageFile)) {
Get the root directory path and append the rest images directory path to it.
ahmed201
(Rifajas)
January 9, 2014, 6:01pm
4
AP81:
Hi,
I currently have some images stored in protected/data/service/. I now need to be able to serve this via the web, so I decided to move them to the <webroot>/images folder.
That solved one problem, but how do I access them in the filesystem? i.e.
i.e. before i could do:
$imageFile = Yii::app()->basePath . Yii::app()->params['IMAGES_SERVICE_DIR_PATH'] . $id . '.jpg';
if (is_file($imageFile)) {
Given that the images are now in <webroot>/images/service, I could probably do something using Yii::getPathOfAlias(‘application’), but I was hoping for a more elegant solution.
Anyone got any ideas?
use Yii::app()->baseUrl.’/images/something.jpg’;