Downloaded croup File in cake php3.6

$response = $this->response->withFile( $file['path'], ['download' => true, 'name' => 'foo'] ); return $response;
dowloading a file but file always crrupted Why so?

Whats the file type? Sometimes you need send the header to browser with the type of the file to work corretly.
Ex:

$this->RequestHandler->respondAs('pdf');
$this->response->withHeader('Content-type', 'application/pdf');
1 Like