diff --git a/src/LiveComponent/doc/index.rst b/src/LiveComponent/doc/index.rst index 4c7b5fc242b..b6ec0b237f6 100644 --- a/src/LiveComponent/doc/index.rst +++ b/src/LiveComponent/doc/index.rst @@ -1326,6 +1326,39 @@ The files will be available in a regular ``$request->files`` files bag:: need to specify ``multiple`` attribute on HTML element and end ``name`` with ``[]``. +.. _downloads: + +Downloading files +----------------- + +Currently, Live Components do not natively support returning file responses directly from a LiveAction. However, you can implement file downloads by redirecting to a route that handles the file response. + +Create a LiveAction that generates the URL for the file download and returns a `RedirectResponse`:: + + #[LiveAction] + public function initiateDownload(UrlGeneratorInterface $urlGenerator): RedirectResponse + { + $url = $urlGenerator->generate('app_file_download'); + return new RedirectResponse($url); + } + +.. code-block:: html+twig + +