我得到了一个文件,当给定一个文件时,它?ordernummer=123456
会从 DB 中获取必要的数据,并使用 FPDF 生成一个 PDF 文件,该文件会强制下载 PDF。工作正常。现在我想从另一个页面调用这个文件,以便在按下按钮或链接时下载 PDF 文件。现在我正在使用include()
,它可以工作,但在我看来不是很优雅。我试过使用file_get_contents();
,但那也不起作用。有没有人有好的解决方案?
$ordernummer = "204377";
$postdata = http_build_query(
array(
'ordernummer' => $ordernummer
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents('http://url.nl/pdf/generate_pakbon.php', false, $context);