【发布时间】:2017-01-16 11:38:52
【问题描述】:
我有一个从文件系统读取的 pdf 文件,现在我可以使用 echo 直接将它显示给用户。这就是我所做的:
$file = $client->open($storage_root);
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . 'sample' . '.pdf"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
echo ($file->getContents());
但我需要以某种方式将此文件保存在临时位置。关于如何做到这一点的任何想法。
帮助感激!
【问题讨论】:
-
请解释将文件存储在临时位置是什么意思
-
@NadirLatif 需要将此 pdf 与我保存在磁盘上的其他 mpdf 对象合并。出于这个原因,我必须将文件保存在磁盘上,例如 ex '/usr/local/temp/xxx.pdf'
-
可以使用php复制功能。它将文件从源复制到目标:php.net/manual/en/function.copy.php