I want to ask everybody is it possible to send images using header() function

header("Content-type: ".$ContentType);

header('Content-Disposition: inline; filename="'.$filename.'"');

and only show that image in web page

<img src=......../>

and how we can do it ?

Thank you


I remember that phpThumb is doing that so here’s the code they use to send images on the fly. The code is in the show() method. I guess it is a good start: https://github.com/masterexploder/PHPThumb/blob/master/src/GdThumb.inc.php#L956

See http://www.yiiframework.com/forum/index.php/topic/34675-use-a-controller-for-an-img-source/page__gopid__166997#entry166997

thank you for your reply, but I didn’t understand what I have to do exacly.

I am sorry for confusing you :)

I ment that I once created this extension: http://www.yiiframework.com/extension/ephpthumb which is a wrapper for phpThumb. phpThub provides you with a show() method that is exactly doing what you want. You could write an action in Yii that is using the show() method to directly output an image (as a preview before it is saved etc.). The code would look like this:

public function actionShowImage($fileName)





Hope it helps

ah yeah, got you, but actually i’m using couchDB and the image is already there. and when i rend this image using the rendrer method as follow

public function render($filename, $die=true) {


	header("Content-type: ".$this->getContentType($filename));

	header('Content-Disposition: inline; filename="'.$filename.'"');




the problem is the image is sent as attachment and it shows only the image in the browser, so i need to use that image in <img/> tag.