douwen9534
2016-07-08 05:16 阅读 37
已采纳

在服务器中存储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.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    drdawt9210 drdawt9210 2016-07-08 07:50

    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."' ;";
    
    点赞 评论 复制链接分享
  • doureng1083 doureng1083 2016-07-08 08:17

    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

    点赞 评论 复制链接分享

相关推荐