I am trying to generate report and upload it. Problem is that when function that generates the file ends with readfile(), it just downloads the file even if I put ob_start()
before the function call. So I don't understand why ob_start
is not catching It.
Problem should be here
I call
ob_start()
Then I call function that outputs file like this
header('Content-Type: application/vnd.openxmlformats-officedocument.' . 'wordprocessingml.document'); header('Content-Disposition: attachment; filename="' . $fileNameDownload . '"'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($fileName . '.' . $this->_extension)); readfile($fileName . '.' . $this->_extension);
After previous function call I put
$content = ob_get_contents();
and 4. ob_end_clen()
I would expect that with readfile()
the function will start to write into buffer, but instead it outputs the file for download