Problem With Showing Images

in my app when a user adds a post he also upload an image to this directory:


in time of showing these images i write this code:

<img class="adpic" src="<?php echo CHtml::encode(Yii::app()->baseUrl.'/'.$data->pic); ?>" />

that $data->pic is uploads/images/ads/somepic.jpg

on localhost its working but not in my online site.

even in online site’s source code url of image is correct and by clicking it shows

the image but not in web page itself.

can anyone help me?


+1 to this… add the pic on your online site it prob will work. i had the same problem and couldnt figure ot out.

the images where in the same path amd same names and didnt render…i just reuploaded the images on my live site and it worked even though nothing changed path and image name wise.

Are the permissions are correct on your uploads folder. Make sure permission given to read/write and recursively. Could you please try this. And also i would suggest to use

<?php echo CHtml::image(Yii::app()->baseUrl.DIRECTORY_SEPARATOR.'test.jpg'); ?>

thanks for your comments but surprisingly my problem was with css file. i remove img class and it works.

i think the Trouble Maker line was

overflow: hidden;

but i can’t understand it’s relation with server. :unsure:


  $baseUrl = Yii::app()->baseUrl;

  $img = $baseUrl.'/upload/liquor/'.$model->liquor_logo;

 if($img!='' && file_exists(Yii::app()->request->baseUrl.'/upload/liquor/').$img) {

	echo CHtml::image($img,'',array("height"=>$height,"width"=>$width)); 


Are you updating your css file in assets folder ?

if yes then i hope you are aware that assets folder contain dyanamic css and js files. which will be created at run time.

And if no then its pretty strange thing why this css property is not working on your server.You have to check your css file correctly.

thanks it is nice dynamic way but not my solution at now.

no it is in css folder an i include it directly.

my img tag just have three property:

overflow: hidden; , max-width and max-height;

i remove overflow and it just works. but yes i must check it accurately when this project finished.

Ahhh…Ok thats good man :)