I am using mPDF
library to generate a pdf from my php
server script. I have used composer
to install the library into my live server file system.
I was being able to generate the pdf
file successfully for quite a couple of months, until today morning. Everytime I try to generate the pdf it shows this error in the console:
Notice: file_get_contents(): Read of 8192 bytes failed with errno=21 Is a directory in /home/user/domains/report_generation/backend_pdfgen/vendor/mpdf/mpdf/src/File/LocalContentLoader.php on line 10
According to the console, I went to line 10 in LocalContentLoader.php. This is the code:
<?php
namespace Mpdf\File;
class LocalContentLoader implements \Mpdf\File\LocalContentLoaderInterface
{
public function load($path)
{
return file_get_contents($path);
}
}
This is my pdf generation script (pdfgen.php):
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once __DIR__ . '/vendor/autoload.php';
$mpdf = new \Mpdf\Mpdf(['setAutoTopMargin' => 'stretch']);
$mpdf->SetTitle("report.pdf");
$mpdf->SetAuthor("Anonymous");
$mpdf->WriteHTML('<div style="text-align:center";>Some data here</div>');
$mpdf->Output("reports/report.pdf");
?>
My file hierarchy
:
I am not being able to understand what's wrong with it. I surfed on the internet and found a post where it was mentioned that I have to increase the upload_max_filesize
, it's already increased to 1 GB, but still the error message shows. Where am I going wrong. Please guide me.
Surprisingly, the error doesn't show when I run the script in my localhost server.