簡體   English   中英

PHP; 將 CSV 導出到 output 緩沖區:加載的文件為空。 為什么?

[英]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 允許您以與printecho相同的方式寫入 output 緩沖區機制。

你正試圖從中讀取,這顯然是做不到的。

我不清楚你實際上想要達到什么目的。

*“空” PHP文件“

[英]An *empty* PHP file “<?php”, when included, doesn't get parsed and is added to Output Buffer instead, why so?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM