php - CakePHP - How do you tell a controller's action to output a raw image header? -
php - CakePHP - How do you tell a controller's action to output a raw image header? -
i'm recoding existing project using cakephp framework. now, in existing code have php file (just called thumb.php) takes file , size , yields resized raw image browser. can utilized in instance image tag or other purposes. "thumbs.php" file uses header('content-type: image/jpeg'); output raw image.
anyway, here in action: http://www.dosspirit.net/php/thumb.php?file=268-transport-tycoon-deluxe-3.png&size=640
(you can alter size parameter 240 or 1240 , image resized you).
now, want replicate behaviour in cakephp.
so far, have setup:
class screenshotcontroller extends appcontroller { public function view() { (some code handle image scaling) } }
looking @ above code, urls screenshot this: http://www.domain/screenshot/view/268-transport-tycoon-deluxe-3.png/640
now, how can tell controller in cakephp output image header instead of going through view etc., hence mimicing functionality thumbs.php file ?
any response appreciated,
sincerely, - bakkelun
there's still php in cakephp. can same thing in action:
public function view() { header('…'); echo $imagedata; exit(); }
having said that, should utilize controller::header
method output raw headers (for overrideable unit tests). better, should utilize media views output images cake way (which requires write file though).
php cakephp image-processing controller
Comments
Post a Comment