I'm trying to read a file and return it with a controller in CakePHP 3.5 and I'm not having much luck.
I have a quick test file sitting in the /webroot directory with 777 permissions and am trying to return it with this code:
public function thumbnail( $order_id = null, $image_id = null ) {
$this->response->withFile( $order_id.'-'.$image_id.'.jpg' );
return $this->response;
}
When I hit that controller (ie. /orders/thumbnail/KC9BW0/1) All I get back in the browser is a zero byte page with 'text/html' type.
I can't find anything on StackOverflow or the web in general giving a simple example of this using the withFile() function in as recommended in the 3.5 documentation. What am I missing?