2014-01-11 3 views
0

Я хочу, чтобы создать ссылку «Загрузить файл mp3», но у меня есть ошибка в моем crontroller, и я не знаю, почему ...SF2 - Моя скачать mp3 ссылка не работает

Мой файл в/TMP/yvm-загрузки/

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; 
    } 

Моя ошибка:

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 

Спасибо вам всем.

С наилучшими пожеланиями,

ответ

0

я решил мою проблему, я даю вам правильный код для загрузки файлов: все

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; 
} 

Спасибо Вам за вас помочь! :)

Смежные вопросы