Call To Url Outside Baseurl

Hello people,

I’m kind of new in Yii framework. So far I can say that it’s an interesting framework to work with.

The problem that I have is the following.

I want to access some image files that their directory is located outside of my Yii’s baseUrl directory but it seems that there is a problem with the url I provide.

My directories’ structure is:

/protected – protected folder of Yii–

/public_html

and inside public_html I have the following folders:

/general

/mysite --where my baseUrl of Yii framework points to–

The images are located inside /general/images/

Someone will say why I don’t have my images folder inside my baseUrl folder but it was already created and it’s kind of 1giga heavy.

I have tried to access the files by using <?php echo Yii::app()->request->baseUrl; ?>/…/general/images/<my image file>.jpg in the source of the image element in the view but no luck…

I have also tried the solution of setManager->publish but nothing again.

Maybe my question is kind silly or simple but if someone can give me a hand I’ll appreciate it.

Also another question but more from curiosity reasons. Is there any way to put the absolute url of the images folder in Yii’s config file and call it directly through my code? something like the baseurl call more or less?

Thanks in advance,

pavanas

  1. create symlink (ln -s)

  2. yes, see params array at the end of config file.

Thanks for your reply ORey and for your suggestions.

The first one I cannot do it because I don’t have access to the server via command line.

The second one I tried it but didn’t work either.

I created a key pair ‘image’=>dirname(FILE).’/../../public_html/general/images’

and when I´m calling it in the view(Yii::app()->params[‘image’]./myimagefilename) nothing happen.

Is there any other solution?

See what dirname(FILE).’/../../public_html/general/images’ is resolved to, and then make sure it it accesible from the web.

Btw I wonder why you need full path in your views.

For displaying images you can use path relative to webroot (I think it would be /general/images in your case)

Haha of course I don’t want to use full urls but relative ones. The problem is, as I mentioned in the fisrt post, that by using relative url I don’t get anything…And I’m totally stucked…But it should be a way…I don’t think Yii limits people on where they should keep their files…

I created test app, tried


<?php echo Yii::app()->request->baseUrl; ?>/../general/images/<my image file>.jpg

and it worked.

What do you get when you’re opening http://your-site.com/myapp/../general/images/<my image file>.jpg in browser?

404? 403? something else?