I have the following script to output an image to the browser wich works fine.
$file_to_output=$_SERVER['DOCUMENT_ROOT'].'/static/imgs/uploads/20110318172207_16.jpg';
header('Content-Type: image/jpeg');
$raw=imagecreatefromjpeg($file_to_output);
// Output the image
imagejpeg($raw);
// Free up memory
imagedestroy($raw);
when I put this exact same code in a view its doesn’t work anymore and give a bunch of stange characters like this:
����JFIF��>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality ��C
What do I have to do to make it work in a view?
You’re not supposed to put that into a view. All view output is buffered, being returned through a Response object later.
This is all response logics, so your action code should look like: