我正在使用此 PHP 代码开始下载,但希望在启动下载之前/之后显示“HTML”,但以下代码会导致空白页面:
输出html的函数:
function writeMsg($msg)
{
echo "<html><body><h2>$msg</h2></body></html>";
}
调用使用:
if(file_exists ($fullpath)) {
//Start Download
ob_start();
writeMsg('Download Started');
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"$fname\"");
header("Content-Transfer-Encoding: binary");
header('Connection: close');
ob_end_flush();
exit();
}