Reputation: 143
I'm having trouble in displaying my uploaded image. The image path at [webapp]/images/products/
First: I want to display it inside CCGridView. I wrote:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'image-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'title',
'filename',
//this is the image displaying part
array(
'type' => 'raw',
'value' => 'CHtml::image(Yii::app()->baseUrl . "/images/products/" . $data->filename)',
),
'product_id',
//
array(
'class'=>'CButtonColumn',
),
),
)); ?>
But the result only became like this:
Second: I also want to display it in view.php
<?php if($model->filename)
$path = Yii::app()->baseUrl. '/../images/products/' . $model->id;
echo CHtml::image($path,
$model->title,
array(
'title' => $model->title,
'style' => 'margin: 10px;',
)); ?>
But the result is:
Please help me solving this. Many thanks!
Upvotes: 1
Views: 3611
Reputation: 365
try this maybe help:
CHtml::image(Yii::app()->baseUrl . "/../images/products/" . $data->filename);
and check is exists file with name $data->filename
Upvotes: 2
Reputation: 49
Please try this..
"value"=>'($data->picture !=="") ? CHtml::image(Yii::app()->request->baseurl."/upload/technician/".$data->picture,"",array(\'width\'=>100, \'height\'=>50)) : ""',
I Hope it will help you...
Upvotes: 0