I have a user profile where i want the image of the user to be displayed along with its information. The information is displayed but not the image. The output is as follows
ID: 141
Member Login:
First Name:
Middle Name:
Last Name:
Gender: 0
Date of birth: 2011-10-17
Upload Photo2:
I want to display the thumbnail of the user. Any ideas how to go about it?
What is stored in your database? If it is the URL of the image (assuming the field is named photo2):
<?php echo CHtml::image($model->photo2); ?>
If is the image it self… then you need to be trickier… you will have to call a controller’s action and push the mime type and the contents of the field
// on your view
<?php echo CHtml::image($this->createUrl('controller/action',array('id'=>$model->id)); ?>
// on the controller's action
$id = Yii::app()->request->getParam('id');
$model = MyModel::model()->findByPk($id);
// whatever the type of the image is
header('content-type: image/jpeg');
// whatever the field name is
echo $model->photo2;
I want to display the thumbnail of the uploaded image. I have used the image helper yii extension and given write permission to the images folder under protected. I am getting the following errors.
getimagesize(C:/xampp/htdocs/profile) [<a href=‘function.getimagesize’>function.getimagesize</a>]: failed to open stream: Permission denied