Hey all,
Am working on a project that involve uploading scanned Identity cards of the Applicants. The system collects residential and employment details of the applicant. A pdf report containing summary of that application is sent to some email address for processing. Up to this point everything works perfectly but i am unable to include the scanned ID as part of this pdf report. I successfully implemented the upload functionality and the file name to db. Including the image to the pdf report is the problem. I Have attached a pdf document to clarify what i mean. please have a look at it.
My controller
<?php
class UploadController extends Controller
{
public function actionIndex()
{
$command = Yii::app()->db->createCommand();
$model=new Upload();
$dir = Yii::getPathOfAlias('application.uploads');
$uploaded = false;
if(isset($_POST['Upload']))
{
$model->attributes=$_POST['Upload'];
$file=CUploadedFile::getInstance($model,'file');
if($model->validate())
{
$uploaded = $file->saveAs($dir.'/'.$file->getName());
$model->filename=$file->getName();
$model->mime_type=$file->getType();
$model->file_size=$file->getSize();
//$dest_name = md5($model->filename=$file->getName());
//$model->file=file_get_contents();
//$model->file_data=file_get_contents($file->tempName);
//$file->saveAs(Yii::app()->getBasePath() . '/../images/dbImages/' . '1.jpg');
}
$model->save();
}
$this->render('index', array(
'model' => $model,
'uploaded' => $uploaded,
'dir' => $dir,
));
}
}
my model
<?php
class Upload extends CActiveRecord
{
public $file;
public function rules()
{
return array(
array('file','file','safe'=>'true','types'=>'png,jpg,jpeg,gif','allowEmpty'=>false),
);
}
}
I have a controller named PdfController and I use Mpdf for conversion of html to pfd. I instantiate the Upload model in it to help me get data in that model in this case the uploaded image.
Like this
......
$UP=Uploads::model()->findByPk(Yii::app()->user->id);
$mPDF1->WriteHTML($this->renderPartial('summary', array('pi'=>$PI,'pa'=>$PA,'ei'=>$EI,'pb'=>$PB,'up'=>$UP), true));
......
And finally i try to echo the Image like this
Applicants Id Photo :
<?php echo $up->filename; ?>
This Doesn’t work for me.
Please help
Thanks in advance.