Clear previous output when openToBrowser() called (#243)
If any character has been outputted before, the generated file will be corrupted.
This commit is contained in:
1 parent
cd38ba093e
commit
8edd8e2401
2 files changed
+15
No files matched your search
@@ -121,6 +121,10 @@ abstract class AbstractWriter implements WriterInterface
|
||||
$this->filePointer = $this->globalFunctionsHelper->fopen('php://output', 'w');
|
||||
$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
|
||||
$this->globalFunctionsHelper->header('Content-Type: ' . static::$headerContentType);
|
||||
$this->globalFunctionsHelper->header('Content-Disposition: attachment; filename="' . $this->outputFilePath . '"');
|
||||
|
||||
Reference in new issue
Block a user