Clear previous output when openToBrowser() called
If any character has been outputted before, the generated file will be corrupted.
This commit is contained in:
parent
cd38ba093e
commit
643d1e102f
@ -252,6 +252,17 @@ class GlobalFunctionsHelper
|
|||||||
header($string);
|
header($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper around global function ob_end_clean()
|
||||||
|
* @see ob_end_clean()
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function ob_end_clean()
|
||||||
|
{
|
||||||
|
ob_end_clean();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper around global function iconv()
|
* Wrapper around global function iconv()
|
||||||
* @see iconv()
|
* @see iconv()
|
||||||
|
@ -121,6 +121,10 @@ abstract class AbstractWriter implements WriterInterface
|
|||||||
$this->filePointer = $this->globalFunctionsHelper->fopen('php://output', 'w');
|
$this->filePointer = $this->globalFunctionsHelper->fopen('php://output', 'w');
|
||||||
$this->throwIfFilePointerIsNotAvailable();
|
$this->throwIfFilePointerIsNotAvailable();
|
||||||
|
|
||||||
|
// Clear any previous output (otherwise the generated file will be corrupted)
|
||||||
|
// @see https://github.com/box/spout/issues/241
|
||||||
|
$this->globalFunctionsHelper->ob_end_clean();
|
||||||
|
|
||||||
// Set headers
|
// Set headers
|
||||||
$this->globalFunctionsHelper->header('Content-Type: ' . static::$headerContentType);
|
$this->globalFunctionsHelper->header('Content-Type: ' . static::$headerContentType);
|
||||||
$this->globalFunctionsHelper->header('Content-Disposition: attachment; filename="' . $this->outputFilePath . '"');
|
$this->globalFunctionsHelper->header('Content-Disposition: attachment; filename="' . $this->outputFilePath . '"');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user