I want to create a link "Download this mp3 file" but I have an error in my crontroller and I doesn't know why...
My file is in /tmp/yvm-download/
public function downloadAction($file)
{
# YoutubeDomwloader object
$YoutubeDownloader = $this->container->get('dimi_yvm.youtubedownloader');
$response = new Response();
$response->setContent(file_get_contents($YoutubeDownloader->_download_directory . $file . '.mp3'));
$response->headers->set('Content-Type', 'application/force-download');
$response->headers->set('Content-disposition', 'filename=' . $file . '.mp3');
return $response;
}
My error:
FatalErrorException: Parse: syntax error, unexpected '$response' (T_VARIABLE) in /var/www/site.com/main.site.com/Symfony2/src/Dimi/YvmBundle/Controller/HomeController.php line 74
Thanks you all.
Best regards,
I have solved my problem, I give you the correct code to download files:
public function downloadAction($file)
{
$response = new Response();
$response->headers->set('Content-Type', 'mime/type');
$response->headers->set('Content-Disposition', 'attachment;filename=' . $file);
$response->setContent($content);
return $response;
}
Thanks you all for you help ! :)