dsj8086 2013-03-15 05:41
浏览 24
已采纳

使用dompdf的phpmailer的动态文件

I am generating pdf file using dompdf whose filename keeps changing as I have assigned a variable in dompdf stream output and this filename always remains as unique filename.

I want to attach a file in my mail where I am using phpmailer.

Problem: Able to attach file properly if I assign a particular file name in phpmailer as static file(with particular name assigned), but not getting successful for dynamic files (using variable as below). Here, $attach is my php variable for file name.

Trying out below code:

$dompdf->stream($attach);//Code for dompdf

$mail->AddAttachment('C:\Downloads\$attach.pdf');  //code for phpmailer to attach file
  • 写回答

1条回答 默认 最新

  • duan19911992 2013-03-15 05:48
    关注

    What i did is like this...........

           I got all my html code in the following variable called `$html`.Then i followed below procedure.
    $dompdf->load_html($html);    
    $dompdf->render();
    $pdf = $dompdf->output();
    $file_location will have dynamic file name.
    file_put_contents($file_location,$pdf);
    

    Now use this $file_location variable for attaching the file name to php mailer. This you need to write in the same php file where you are generating pdf.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?