Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PDF不能使用php存储在文件夹中_Php_Html_Dompdf - Fatal编程技术网

PDF不能使用php存储在文件夹中

PDF不能使用php存储在文件夹中,php,html,dompdf,Php,Html,Dompdf,我试图将我的pdf文件存储在数据库中的文件夹中。但它仅适用于MAMP服务器。我的代码如下: $dompdf->load_html($html); $dompdf->set_paper("A4", "landscape"); $dompdf->render(); $dompdf->stream($projectdetail->project_name." - Cost Report.pdf", array("Attachment" => false));

我试图将我的pdf文件存储在数据库中的文件夹中。但它仅适用于MAMP服务器。我的代码如下:

$dompdf->load_html($html);
$dompdf->set_paper("A4", "landscape");
$dompdf->render();

 $dompdf->stream($projectdetail->project_name." - Cost Report.pdf", array("Attachment" => false));
 $canvas = $dompdf->get_canvas();
 $font = Font_Metrics::get_font("helvetica", "bold");
 $canvas->page_text(750, 570, "Page: {PAGE_NUM} of {PAGE_COUNT}", $font, 6, array(0,0,0));
 $canvas->page_text(25, 570, "II International P Ltd", $font, 6, array(0,0,0));
 $output = $dompdf->output();
 $file_to_save = '../files/'.$projectdetail->project_name.'/'.$projectdetail->project_name.'.pdf';
 file_put_contents($file_to_save, $output);

有人能帮我吗?

在代码的早期,您调用
$dompd->stream()
。此方法流化PDF并停止脚本的执行。我不知道为什么它在MAMP上工作,但在其他服务器上不工作,但是如果你重新安排你的脚本,你应该会有更多的运气

$dompdf->load_html($html);
$dompdf->set_paper("A4", "landscape");
$dompdf->render();

$canvas = $dompdf->get_canvas();
$font = Font_Metrics::get_font("helvetica", "bold");
$canvas->page_text(750, 570, "Page: {PAGE_NUM} of {PAGE_COUNT}", $font, 6, array(0,0,0));
$canvas->page_text(25, 570, "II International P Ltd", $font, 6, array(0,0,0));
$output = $dompdf->output();

$file_to_save = '../files/'.$projectdetail->project_name.'/'.$projectdetail->project_name.'.pdf';
file_put_contents($file_to_save, $output);

$dompdf->stream($projectdetail->project_name." - Cost Report.pdf", array("Attachment" => false));

您是否尝试过这样->“文件/”。$projectdetail->project_name./'.$projectdetail->project_name..pdf';s但不起作用您是否尝试过dirname(文件)