在服务器中存储fpdf输出并在数据库中添加文件名

在服务器中存储fpdf输出并在数据库中添加文件名

问题描述:

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.

我正在使用fpdf库生成发票,该库从数据库中获取数据,现在生成pdf时我想保存 文件夹中的文件,并在数据库中添加日期的文件名,以便我可以获取之前在表格中生成的所有发票。请在这里帮助我。 p> div>

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