Reputation: 21
File resource - fopen('php://output')
Header list:
Content-Type: application/csv
Content-Disposition: attachment; filename="test.csv"
Cache-Control: max-age=0
Expires: 0
Cache-Control: must-revalidate
Pragma: public
How i download:
ob_clean();
readfile("php://output");
exit;
ob_get_contents() before readfile is not empty and data which i write to file too.
But loaded file is empty. Why
Upvotes: 1
Views: 324
Reputation: 16741
https://www.php.net/manual/en/wrappers.php.php#wrappers.php.output
Says:
php://output
is a write-only stream that allows you to write to the output buffer mechanism in the same way as print and echo.
You're trying to read from it, which clearly cannot be done.
It is unclear to me what you're actually trying to achieve.
Upvotes: 1