Reputation: 4546
I am working in Yii.
I am trying to get an image which I have stored inside the protected/members/img.jpg
but the image is not showing, however, I am trying to get the image when I put it outside the
protected folder and it is getting displayed.
The .htaccess
inside the protected folder has : deny from all
Is there something in it that I need to change to achieve what I am trying for??
Is there any method of getting the image which is stored inside the protected folder??
Upvotes: 1
Views: 1341
Reputation: 266
assetManagerFiles inside the "protected" folder are not accessible from the client browser. This prevents people to have access to important files, like your source code.
If you want to store images inside "protected" and want them to be accessible, you need to publish them using CAssetManager.
Usage is something like:
$path = Yii::app()->basePath.'/path-inside-protected';
$yourImageUrl = Yii::app()->assetManager->publish($path);
Yii will then use the file as an asset, coping it to the "assets" folder, sibling to "protected". After that, you can just use the url returned on your HTML.
<img src="<?php echo $yourImageUrl ?>">
Upvotes: 3