将 fpdf 输出存储在服务器中并在数据库中添加文件名
storing fpdf output in server and add filename in database
我正在使用从数据库中获取数据的 fpdf 库生成发票,现在当生成 pdf 文件时,我想将文件保存在一个文件夹中,并在数据库中添加带有日期的文件名,以便我可以获取所有发票之前在 table.Please 中生成,请帮助我。
确保您可以写入目录。
$filename="/Mydirectory/bill01.pdf";
保存 Pdf。
$pdf->Output($filename,'F');
更新 Sql 表
$query=" UPDATE `shopdb`.`bills` SET `bill_doc_crea` = '1', `bill_pdf_doc` = '".$filename."' WHERE `bills`.`ordernummer` ='".$orderId."' ;";
Output([string dest [ string name [ boolean isUTF8]]])
发送文档的目的地。它可以是以下之一:
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.
通常参数 F 应该只保存到磁盘。
看起来 fpdf 正在强制下载。
在这种情况下,使用 tcpdf https://tcpdf.org/ 应该很有用。
我用它,效果很好。保存到磁盘并插入 DB
我正在使用从数据库中获取数据的 fpdf 库生成发票,现在当生成 pdf 文件时,我想将文件保存在一个文件夹中,并在数据库中添加带有日期的文件名,以便我可以获取所有发票之前在 table.Please 中生成,请帮助我。
确保您可以写入目录。
$filename="/Mydirectory/bill01.pdf";
保存 Pdf。
$pdf->Output($filename,'F');
更新 Sql 表
$query=" UPDATE `shopdb`.`bills` SET `bill_doc_crea` = '1', `bill_pdf_doc` = '".$filename."' WHERE `bills`.`ordernummer` ='".$orderId."' ;";
Output([string dest [ string name [ boolean isUTF8]]])
发送文档的目的地。它可以是以下之一:
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.
通常参数 F 应该只保存到磁盘。
看起来 fpdf 正在强制下载。
在这种情况下,使用 tcpdf https://tcpdf.org/ 应该很有用。
我用它,效果很好。保存到磁盘并插入 DB