Reputation: 43
I have successfully created a PDF document using FPDF but cannot get it to save to a folder on the server. I am able to output the PDF document to the browser.
I have also allowed permission to write to this folder 'fullSizeA4PdfPage':
drwxrwxrw-
My PHP code:
require('fpdf181/fpdf.php');
$pdf = new FPDF('P','pt','A4');
$pdf->AddPage();
$pdf -> Image($pathToImage, $centreX, $centreY, $imageWidth, $imageHeight);
// SAVE A4PDF FILE TO LOCAL DIR ('/fullSizeA4PdfPage')
$nameA4PDF = 'A4PdfPage.pdf';
$A4PDFPageFolder = 'fullSizeA4PdfPage';
$localPathA4PFD = $A4PDFPageFolder.'/'.$nameA4PDF;
$pdf -> Output('F', $localPathA4PFD); // LINE 80 I have also tried $pdf -> Output($localPathA4PFD, 'F' );
I am getting the following error from the browser:
Warning: file_put_contents(fullSizeA4PdfPage/A4PdfPage.pdf): failed to open stream: No such file or directory in /var/www/html/labbook_aws/lab_server/fpdf181/fpdf.php on line 1021
Upvotes: 0
Views: 1543
Reputation: 2524
With permissions of
drwxrwxrw-
processes running under a user who is not the same or in the same group as the owner cannot access the content of the directory (note the missing last x
). So try permissions of 777
instead of 776
if your script runs under a different user than the owner of the directory.
See also this question for a discussion of the meaning of the x
bit. It seems that even though rw
should be sufficient to read and write files in a directory, without the x
the meta data of the files cannot be read, so some functions may not be able to open the file at all.
Upvotes: 0