[英]PHP; Export CSV to output buffer: Loaded File is empty. Why?
文件資源- fopen('php://output')
Header列表:
Content-Type: application/csv
Content-Disposition: attachment; filename="test.csv"
Cache-Control: max-age=0
Expires: 0
Cache-Control: must-revalidate
Pragma: public
我如何下載:
ob_clean();
readfile("php://output");
exit;
readfile 之前的 ob_get_contents() 不為空,並且我也寫入文件的數據。
但是加載的文件是空的。 為什么
https://www.php.net/manual/en/wrappers.php.php#wrappers.php38D14CE6621FDB363
說:
php://output
是只寫的 stream 允許您以與print和echo相同的方式寫入 output 緩沖區機制。
你正試圖從中讀取,這顯然是做不到的。
我不清楚你實際上想要達到什么目的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.