/** * @Route("/download/{id}", name="ac_media_bundle_file_download") */ public function downloadAction(\AC\MediaBundle\Entity\File $file) { ini_set('memory_limit', '-1'); $doc = $this->container->getParameter('app_root_files'); $doc .= \AC\MediaBundle\Services\EvenementService::generateUrl($file->getEvenement()); $doc .= $file->getName(); $response = new \Symfony\Component\HttpFoundation\Response(); $response->setContent(file_get_contents($doc)); $response->headers->set('Content-Type', 'audio'); // modification du content-type pour forcer le téléchargement (sinon le navigateur internet essaie d'afficher le document) $response->headers->set('Content-disposition', 'filename=' . $file->getName()); return $response; }