[英]Flush make my PHP script to stop
我有一段代碼可以強制php
頁面download
服務器上托管的文件。 現在問題出在代碼段之后,如果我們編寫了其他任何php代碼,它就不會執行。
<?php
$file = "http://some_server/downloads/file_to_download.pdf";
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
// flush();
readfile($file);
$var = "This is a variable";
echo "Hello test. ".$var;
?>
我已經找到了解決方案! 我只是將上面piece of code
粘貼在它的底部!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.