I am generating invoices using fpdf library which fetches data from database,now when the pdf is generated i want to save the file in a folder and add the file name with date in database so that i can fetch the all invoices generated previously in a table.Please help me out here.
Be shure that you can write to the directory.
$filename="/Mydirectory/bill01.pdf";
Save the Pdf.
$pdf->Output($filename,'F');
Update the Sql Tables
$query=" UPDATE `shopdb`.`bills` SET `bill_doc_crea` = '1', `bill_pdf_doc` = '".$filename."' WHERE `bills`.`ordernummer` ='".$orderId."' ;";
Output([string dest [, string name [, boolean isUTF8]]])
Destination where to send the document. It can be one of the following:
I: send the file inline to the browser. The PDF viewer is used if available.
D: send to the browser and force a file download with the name given by name.
F: save to a local file with the name given by name (may include a path).
S: return the document as a string.
Normally the Parameter F should only save to disk.
It looks that fpdf are forcing download. In this case use of tcpdf https://tcpdf.org/ should be useful. I use it and it works fine. Save to disk and insert in DB