国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

php://output 導(dǎo)出excel 第一次請(qǐng)求OK, 再請(qǐng)求第二次就報(bào)錯(cuò)了

php2py

問題描述

導(dǎo)出Excel php://output 直接返回response 第一次請(qǐng)求OK, 再請(qǐng)求第二次就報(bào)錯(cuò)了

程序代碼


header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header("Content-Disposition: attachment;filename=".$Excel['fileName'].".xlsx");
header('Cache-Control: max-age=0');//禁止緩存
$writer = new Xlsx($spreadsheet);
$writer->save('php://output');

$c = ob_get_contents();
ob_flush();
flush();
$response = response();
$response->withHeaders([
    'Content-Type' => 'application/vnd.ms-excel',
    'Content-Disposition' => 'attachment;filename="'.$fileName.'"',
    'Cache-Control' => 'max-age=0',
])->withBody($c);
ob_clean();
return $response;

報(bào)錯(cuò)信息

Cannot modify header information - headers already sent by (output started at E:\\GitProject\\webman-admin\\BackEnd\\app\\common\\controller\\Manage.php:199)

截圖報(bào)錯(cuò)信息里報(bào)錯(cuò)文件相關(guān)代碼

截圖
截圖

第二次請(qǐng)求就報(bào)錯(cuò)了
截圖

操作系統(tǒng)及workerman/webman等框架組件具體版本

window10
webman: 1.4.3
php: 7.4

1452 1 1
1個(gè)回答

php2py

解決了,原來(lái)是我在response之前輸出了header內(nèi)容

  • 暫無(wú)評(píng)論
年代過(guò)于久遠(yuǎn),無(wú)法發(fā)表回答
??