maher
(Elaissimaher)
August 17, 2012, 4:10pm
1
Hi
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
Haensel
(Johannes)
August 17, 2012, 4:21pm
2
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
Haensel
(Johannes)
August 17, 2012, 4:26pm
3
maher
(Elaissimaher)
August 20, 2012, 12:52pm
4
thank you for your reply, but I didn’t understand what I have to do exacly.
Haensel
(Johannes)
August 20, 2012, 5:26pm
5
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)
{
$thumb=Yii::app()->phpThumb->create('../images/'.$fileName);
$thumb->show();
}
Hope it helps
maher
(Elaissimaher)
August 21, 2012, 6:48am
6
Haensel:
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)
{
$thumb=Yii::app()->phpThumb->create('../images/'.$fileName);
$thumb->show();
}
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.'"');
echo($this->getBinary($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.