Yii Framework Forum: How To Display Blob Image On Tcpdf In Yii? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Display Blob Image On Tcpdf In Yii? Rate Topic: -----

#1 User is offline   Ramione 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 08-December 11
  • Location:Marikina, Philippines

Posted 02 April 2013 - 12:19 AM

Is there a way to display a blob image in TCPDF in Yii? I've tried calling the function below but it just returns a blank picture.

My controller:
public function actionDisplayAgencyIcon()
{
        $info = BaseAgencyInfo::model()->find();
        $id = $info->agencyID;

        if($id == null || trim($id)=='') {
        echo "error in image, bad ID value [{$id}]";
        exit();
        }

        $model=BaseAgencyInfo::model()->find("agencyID = '{$id}'");

        if($model->agency_logo == null){
        echo "error in image, using ID [{$id}] ";
        exit();
        }

header('Content-Type: gif,jpeg,png');
echo $model->agency_logo;
}


So, any ideas how to achieve this?
0

#2 User is offline   Balu 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 152
  • Joined: 09-August 11
  • Location:Kerala, India

Posted 02 April 2013 - 01:47 AM

View PostRamione, on 02 April 2013 - 12:19 AM, said:

Is there a way to display a blob image in TCPDF in Yii? I've tried calling the function below but it just returns a blank picture.

My controller:
public function actionDisplayAgencyIcon()
{
        $info = BaseAgencyInfo::model()->find();
        $id = $info->agencyID;

        if($id == null || trim($id)=='') {
        echo "error in image, bad ID value [{$id}]";
        exit();
        }

        $model=BaseAgencyInfo::model()->find("agencyID = '{$id}'");

        if($model->agency_logo == null){
        echo "error in image, using ID [{$id}] ";
        exit();
        }

header('Content-Type: gif,jpeg,png');
echo $model->agency_logo;
}


So, any ideas how to achieve this?





Can you check with this code

in controller


public function actionDisplaySavedImage()
                {
                        $model=$this->loadModel($_GET['id']);
                 
                        header('Pragma: public');
                        header('Expires: 0');
                        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                        header('Content-Transfer-Encoding: binary');
                        header('Content-length: '.$model->photo_file_size);
                        header('Content-Type: '.$model->photo_content_type);
                        header('Content-Disposition: attachment; filename='.$model->photo_file_name);
                 
                                //echo '<img src="'.base64_decode($model->photo_data).'" />';
                                echo $model->photo_data;
                }


in view

echo '<img class="imgbrder" src="'.$this->createUrl('DisplaySavedImage&id='.$model->primaryKey).'" alt="'.$model->photo_file_name.'" width="101" height="107" />';


Make necessary change to suit to your code structure, This may help you
1

#3 User is offline   Ƒяąȼţąℓ ϻɨɲď 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 61
  • Joined: 04-May 12

Posted 18 October 2013 - 10:41 PM

View PostBalu, on 02 April 2013 - 01:47 AM, said:

Can you check with this code

in controller


public function actionDisplaySavedImage()
                {
                        $model=$this->loadModel($_GET['id']);
                 
                        header('Pragma: public');
                        header('Expires: 0');
                        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                        header('Content-Transfer-Encoding: binary');
                        header('Content-length: '.$model->photo_file_size);
                        header('Content-Type: '.$model->photo_content_type);
                        header('Content-Disposition: attachment; filename='.$model->photo_file_name);
                 
                                //echo '<img src="'.base64_decode($model->photo_data).'" />';
                                echo $model->photo_data;
                }


in view

echo '<img class="imgbrder" src="'.$this->createUrl('DisplaySavedImage&id='.$model->primaryKey).'" alt="'.$model->photo_file_name.'" width="101" height="107" />';


Make necessary change to suit to your code structure, This may help you



I had to sign in just to thank you sir. You are a gentlemen and a scholar. :lol:
0

#4 User is offline   Balu 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 152
  • Joined: 09-August 11
  • Location:Kerala, India

Posted 18 October 2013 - 11:14 PM

View PostƑяąȼţąℓ ϻɨɲď, on 18 October 2013 - 10:41 PM, said:

I had to sign in just to thank you sir. You are a gentlemen and a scholar. :lol:


thank you..
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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