diff --git a/Symfony/Controller/DownloadAction.php b/Symfony/Controller/DownloadAction.php index 88e47a7..62191d4 100644 --- a/Symfony/Controller/DownloadAction.php +++ b/Symfony/Controller/DownloadAction.php @@ -122,11 +122,20 @@ private function createDownloadResponse( $disposition = $response->headers->makeDisposition( $forceDownload ? ResponseHeaderBag::DISPOSITION_ATTACHMENT : ResponseHeaderBag::DISPOSITION_INLINE, - $fileName + $this->sanitizeFileName($fileName) ); $response->headers->set('Content-Disposition', $disposition); $response->headers->set('Content-Type', $mimeType ?: 'application/octet-stream'); return $response; } + + private function sanitizeFileName(string $fileName): string + { + return str_replace( + ' ', + '_', + $fileName + ); + } }