Greetings community, once again needing the forum to solve something that I could not solve, I need to show an image saved in the BD in a report, I am doing it with mpdf, the problem is that the image is not shown in the report , I am going to show an image of the report so that they observe that it is not seen, in the image that I am going to see two images image 1 and image 2, the first one is shown because it is an image taken from a location or directory with this code:
<img src="images/banner/logo.png">
the second is not shown (photo of the person), it is also imported for a folder but it is uploaded through the BD, that is if in the table which I use has 1000 articles, then there are 1000 images in that destination folder and the What you want to show is the one that contains the id of the article, I put the code with which I try to obtain the image:
<?php
$dbImage = Yii::app()->createUrl('/tblDatosc/displaySavedImage', array('id' => $model->Id));
echo CHtml::image($dbImage, 'foto', array('width' => 100, 'height' => 100));
?>
in my controller:
public function actionDisplaySavedImage($id) {
$model = $this->loadModel($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->imagesize);
header('Content-Type: ' . $model->imagetype);
header('Content-Disposition: attachment; filename=' . $model->imagename);
echo $model->foto;
}
in the model:
public function beforeSave() {
if ($file = CUploadedFile::getInstance($this, 'foto')) {
$this->imagename = $file->name;
$this->imagetype = $file->type;
$this->imagesize = $file->size;
$this->foto = file_get_contents($file->tempName);
}
return parent::beforeSave();
}
I await your answers, if it could not be resolved with mpdf, I need another extension, to show me the photo stored in the BD