display an image saved in a variable

How can you display an image saved in a variable?

Let’s say that the image is saved in $model->image, which is returned from the database.

I used




echo CHtml::image($model->image, 'image', 

		 array("class" => "clickme", "width"=>"300", "height"=>"300"));



But it doesn’t work.

Anyone has any ideas?

Thanks!

Is your $model->image a binary(BLOB)?

Or is it a file name(string)?

Is a blob.

Then you have to take some other means to display the image.

The 1st parameter to CHtml::image() should be a string that refers to the URL of image.

http://www.yiiframework.com/doc/api/1.1/CHtml/#image-detail

[EDIT]

These forum topics might be a help.

http://www.yiiframework.com/forum/index.php/topic/12590-mysql-image/

http://www.yiiframework.com/forum/index.php/topic/20660-how-to-display-image-stored-in-database/