Created
April 5, 2011 12:02
-
-
Save caefer/903474 to your computer and use it in GitHub Desktop.
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
| <?php | |
| namespace MyProject\MyBundle\Controller; | |
| use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
| use Symfony\Component\HttpFoundation\Response; | |
| class ImageController extends Controller | |
| { | |
| public function proxyAction($url) | |
| { | |
| $url = urldecode($url); | |
| switch (strtolower(pathinfo($url, PATHINFO_EXTENSION))) { | |
| case 'gif': | |
| $contentType = 'image/gif'; | |
| break; | |
| case 'jpg': | |
| $contentType = 'image/jpeg'; | |
| break; | |
| case 'png': | |
| $contentType = 'image/png'; | |
| break; | |
| } | |
| $response = new Response(file_get_contents($url)); | |
| $response->headers->set('Content-Type', $contentType); | |
| return $response; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment