I have a database that is on a sqlsrv. I have managed to connect to it CI and I can retrieve the data.
All that works very well indeed. My problem is with a PDF that is stored in a varbinay filed.
I can access the field and I get the data, but somehow the data seems to short. Something seems missing.
I use file_put_contents to save the data as an external file but when I open it I get an error message that the PDF is corrupt and cannot be repaired.
this is the sql from the model that I use
SELECT f.stid, f.fieldpcl
FROM SightTest.fieldspcl AS f
INNER JOIN customer.customers AS c ON c.customerid = f.customerid
WHERE c.customerid IN ('$id')
and this is the code
$data['fieldspcl'] = $this->vera_model->getFieldspcl($id);
if ( ! empty ($data['fieldspcl'])){
//create physical files
$filename = $this->config->item('root_folder') . "/pdf/{$id}-{$data['fieldspcl']->stid}.pdf";
$data['fieldspcl']->filename = $this->config->item('base_url'). "/pdf/{$id}-{$data['fieldspcl']->stid}.pdf";
file_put_contents($filename, $data['fieldspcl']->fieldpcl);
}
When I look at the PDF and a PDF that works I see that for example %%EOF is missing at the end. But even adding that did not help
Any help would be creatly appriciated.
All that works very well indeed. My problem is with a PDF that is stored in a varbinay filed.
I can access the field and I get the data, but somehow the data seems to short. Something seems missing.
I use file_put_contents to save the data as an external file but when I open it I get an error message that the PDF is corrupt and cannot be repaired.
this is the sql from the model that I use
SELECT f.stid, f.fieldpcl
FROM SightTest.fieldspcl AS f
INNER JOIN customer.customers AS c ON c.customerid = f.customerid
WHERE c.customerid IN ('$id')
and this is the code
$data['fieldspcl'] = $this->vera_model->getFieldspcl($id);
if ( ! empty ($data['fieldspcl'])){
//create physical files
$filename = $this->config->item('root_folder') . "/pdf/{$id}-{$data['fieldspcl']->stid}.pdf";
$data['fieldspcl']->filename = $this->config->item('base_url'). "/pdf/{$id}-{$data['fieldspcl']->stid}.pdf";
file_put_contents($filename, $data['fieldspcl']->fieldpcl);
}
When I look at the PDF and a PDF that works I see that for example %%EOF is missing at the end. But even adding that did not help
Any help would be creatly appriciated.