<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends AbstractController
{
/**
* @Route("/", name="default")
*/
public function index()
{
return $this->render('main/index.html.twig', [
'controller_name' => 'DefaultController',
]);
}
/**
* @Route("/administracion", name="default")
*/
public function indexAdministracion()
{
return $this->render('administracion/index.html');
}
/**
* @param $filename
* @Route("/download/{filename}")
*
*/
public function downloadAction($filename)
{
// $request = $this->get('request');
/* $path = $this->get('kernel')->getRootDir(). "/../public/downloads/";
$content = file_get_contents($path.$filename);
$response = new Response();
//set headers
$response->headers->set('Content-Type', 'mime/type');
$response->headers->set('Content-Disposition', 'attachment;filename="'.$filename);
$response->setContent($content);*/
$response = new BinaryFileResponse("/download/".$filename);
return $response;
}
}