2

I'm using PHP to put together a PDF using FPDF, right at the bottom I have this:

$pdf->Output("../uploads/filename.pdf",'F');
header("location:../uploads/filename.pdf");

The top line should save the PDF to the uploads folder in the root, and the bottom should show it in the browser. I get this message:

FPDF error: Unable to create output file: ../uploads/filename.pdf

I've even tried making the file path using a variable as suggested in other posts on this site but I still get the same error. I have 777 permissions set throughout the uploads folder too. Thanks.

ERushforth
  • 186
  • 2
  • 6
  • 17

2 Answers2

0

I've actually figured it out, it's a weird fix but it works.

$path = "../../../../uploads/AAA.pdf";
$pdf->Output($path,'F');
header('location:'.$path);

I had to keep jumping back to the root, then go into the /uploads/ folder specifically. Thanks for the answers so far.

ERushforth
  • 186
  • 2
  • 6
  • 17
0
$path=$_SERVER['DOCUMENT_ROOT']."/unwant/test3.pdf";
$pdf->Output($path,'F');

use this code easy to save file dir