My controller looks like this:
public function download($filepath)
{
// Generate response
$response = new Response();
// Set headers
$response->headers->set('Cache-Control', 'private');
$response->headers->set('Content-type', mime_content_type($filepath));
$response->headers->set('Content-Disposition', 'attachment; filepath="' . basename($filepath) . '";');
$response->headers->set('Content-length', filesize($filepath));
// Send headers before outputting anything
$response->sendHeaders();
$response->setContent(readfile($filepath));
}
Passing a filepath to it results in the following error message:
Call to undefined function MyBundle\Controller\mime_content_type()
How can I solve this problem?