Yii Framework Forum: Header() - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Header() display image using header() function Rate Topic: -----

#1 User is offline   maher 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 31-July 12
  • Location:Edmonton

Posted 17 August 2012 - 11:10 AM

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
:-*
0

#2 User is offline   Haensel 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 442
  • Joined: 14-January 11
  • Location:Vienna (Austria)

Posted 17 August 2012 - 11:21 AM

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/m...mb.inc.php#L956
0

#3 User is offline   Haensel 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 442
  • Joined: 14-January 11
  • Location:Vienna (Austria)

Posted 17 August 2012 - 11:26 AM

See http://www.yiiframew...997#entry166997
0

#4 User is offline   maher 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 31-July 12
  • Location:Edmonton

Posted 20 August 2012 - 07:52 AM

View PostHaensel, on 17 August 2012 - 11:26 AM, said:




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

#5 User is offline   Haensel 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 442
  • Joined: 14-January 11
  • Location:Vienna (Austria)

Posted 20 August 2012 - 12:26 PM

I am sorry for confusing you :)

I ment that I once created this extension: http://www.yiiframew...nsion/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
0

#6 User is offline   maher 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 31-July 12
  • Location:Edmonton

Posted 21 August 2012 - 01:48 AM

View PostHaensel, on 20 August 2012 - 12:26 PM, said:

I am sorry for confusing you :)

I ment that I once created this extension: http://www.yiiframew...nsion/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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users