Display Blob Image

Hi all , :)

I have issue with my application.

I can save my images in blob field of database. But when I try to display, it gives error message “Property “ImageTableController.model” is not defined.” i tried for this. But I can’t find the error. Can anyone help me plz…

here is my controller.


 public function actionloadImage($id)

    {

        $model=$this->loadModel($id);

        $this->renderPartial('image', array(

            'model'=>$model

        ));

    }




array('allow', // allow authenticated user to perform 'create' and 'update' actions

                'actions'=>array('create','update','loadImage','delete'),

                'users'=>array('@'),

),



Here is my view…


<?php

header('Content-Type: ' . $model->fileType);

print $model->image; 

exit(); 

?>


echo CHtml::image(Yii::app()->controller->createUrl('image_table/loadImage', array('id'=>$this->model->id)));

The error is because of this line:




array('id'=>$this->model->id)



You should just be using $model->id.

I tried for that also… But it is not work. I wrote view file for actionloadImage. I named it as loadimage.php. is that ok. I’m new for yii. So i can’t identify the error. Please help me…

This is my view file.


<?php

header('Content-Type: ' . $model->fileType);

print $model->image; 

exit(); 

?>

I wouldn’t bother with the view, just output the file straight from the action:




    public function actionloadImage($id)

    {

        $model=$this->loadModel($id);


        header('Content-Type: ' . $model->fileType);

        echo $model->image;

        Yii::app()->end();

    }



What specific problems are you getting when you do this?

Thank you very much :)