Created
February 8, 2016 00:31
-
-
Save aliemre/c8ced6139483a3047c11 to your computer and use it in GitHub Desktop.
Download / Show Headers for Symfony2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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