简体   繁体   English

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

[英]storing fpdf output in server and add filename in database

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

Be shure that you can write to the directory. 请确保您可以写入目录。

$filename="/Mydirectory/bill01.pdf";

Save the Pdf. 保存PDF。

$pdf->Output($filename,'F');

Update the Sql Tables 更新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]]]) 输出([字符串目标[,字符串名称[,布尔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. 通常,参数F仅应保存到磁盘。
It looks that fpdf are forcing download. 看来fpdf强迫下载。 In this case use of tcpdf https://tcpdf.org/ should be useful. 在这种情况下,使用tcpdf https://tcpdf.org/应该会很有用。 I use it and it works fine. 我用它,它工作正常。 Save to disk and insert in DB 保存到磁盘并插入数据库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM