Ali Zia
Ali Zia

Reputation: 3875

using dompdf in codeigniter not making pdfs on live

I am creating pdfs using this code

$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$pdf = $dompdf->output();
file_put_contents($this->config->item('file_path') . $pdf_name, $pdf);
$data['pdf'] = site_url('uploads/pdf/' . $pdf_name);

It works perfectly on XMPP localhost, but on LIVE server I get this error.

A PHP Error was encountered
<p>Severity: Warning</p>
<p>Message:  file_put_contents(/home/xyz/public_html/abc/uploads/pdf/quotation_1502863603.pdf): failed to open stream: No such file or directory</p>
<p>Filename: controllers/Admin.php</p>
<p>Line Number: 742</p>

Please guide me what could be the issue on a LIVE server?

Upvotes: 2

Views: 734

Answers (2)

Abdulla Nilam
Abdulla Nilam

Reputation: 38584

Wrong in here $this->config->item('file_path') (path - /home/xyz/public_html/abc/uploads/pdf/). This path belongs to localhost and not to the server.

You should have try

$pdf_path = 'uploads/pdf/'.$pdf_name;
file_put_contents($pdf_path, $pdf);

Codeigniter Environment nothing to do with hosting path, its need an only relative path. As well check permeation on upload path (777)

Upvotes: 1

Rajapandian
Rajapandian

Reputation: 216

use terminal to check the path of the folder cd /home/xyz/public_html/abc/uploads/pdf/

in above command, folder is available then next check for permission (should be writable - 755)

Upvotes: 0

Related Questions