User1988
User1988

Reputation: 1997

how to display image in yii using CHtml::image()?

i have stored pdf.png in C:\wamp\www\pipelinespark\images\pdf.png

i have used $imghtml=CHtml::image('pdf.png'); then i getting error like.

"NetworkError: 404 Not Found - pipelinespark/administrator/index.php/spark/pdf.png".

Thanks in advance.

Upvotes: 3

Views: 8374

Answers (3)

A l w a y s S u n n y
A l w a y s S u n n y

Reputation: 38552

All of them works for me

<?=CHtml::image(Yii::app()->request->baseUrl."/path-to-images/logo.png", "LOGO")?>
<?=CHtml::image(Yii::app()->baseUrl."/path-to-images/logo.png")?>
<?php echo CHtml::image(Yii::app()->basePath."/../images/profile-image/".$data->avatar); ?>

Upvotes: 0

Suman
Suman

Reputation: 1

<?php echo CHtml::image(Yii::app()->baseUrl . "/images/" . $data->image); ?>

Where $data is the returned value form actionIndex

Upvotes: 0

Dency G B
Dency G B

Reputation: 8146

This works for me!

<?php
 echo CHtml::image(Yii::app()->request->baseUrl.'/path_to/images /'."$model->logo","$model->Name",array('width'=>100,'height'=>100));?>

Upvotes: 5

Related Questions