File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -562,22 +562,26 @@ Serving Files
562
562
When sending a file, you must add a ``Content-Disposition `` header to your
563
563
response. While creating this header for basic file downloads is easy, using
564
564
non-ASCII filenames is more involving. The
565
- :method: `Symfony\\ Component\\ HttpFoundation\\ ResponseHeaderBag ::makeDisposition `
565
+ :method: `Symfony\\ Component\\ HttpFoundation\\ HeaderUtils ::makeDisposition `
566
566
abstracts the hard work behind a simple API::
567
567
568
+ use Symfony\Component\HttpFoundation\HeaderUtils;
568
569
use Symfony\Component\HttpFoundation\Response;
569
570
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
570
571
571
572
$fileContent = ...; // the generated file content
572
573
$response = new Response($fileContent);
573
574
574
- $disposition = $response->headers-> makeDisposition(
575
- ResponseHeaderBag ::DISPOSITION_ATTACHMENT,
575
+ $disposition = HeaderUtils:: makeDisposition(
576
+ HeaderUtils ::DISPOSITION_ATTACHMENT,
576
577
'foo.pdf'
577
578
);
578
579
579
580
$response->headers->set('Content-Disposition', $disposition);
580
581
582
+ .. versionadded :: 4.2
583
+ The static ``HeaderUtils::makeDisposition() `` method was introduced in Symfony 4.2.
584
+
581
585
Alternatively, if you are serving a static file, you can use a
582
586
:class: `Symfony\\ Component\\ HttpFoundation\\ BinaryFileResponse `::
583
587
You can’t perform that action at this time.
0 commit comments