Skip to content

Instantly share code, notes, and snippets.

@aliemre
Created February 8, 2016 00:31
Show Gist options
  • Save aliemre/c8ced6139483a3047c11 to your computer and use it in GitHub Desktop.
Save aliemre/c8ced6139483a3047c11 to your computer and use it in GitHub Desktop.
Download / Show Headers for Symfony2
$response = new Response();
$response->headers->set('Cache-Control', 'private');
$response->headers->set('Content-type', mime_content_type($image));
$response->headers->set('Content-length', filesize($image));
$response->headers->set('Content-Disposition', 'attachment; filename="' . basename($image) . '";');
$response->sendHeaders();
$response->setContent(readfile($image));
return $response;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment