Skip to content

Commit 37df732

Browse files
authored
Merge pull request #4871 from cakephp/issue-4869
Add examples for pre 3.4.0
2 parents 338d726 + 85ca1fc commit 37df732

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

en/controllers/request-response.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,13 @@ You can accomplish that by using :php:meth:`Cake\\Http\\Response::withFile()`::
495495
return $response;
496496
}
497497

498+
// Prior to 3.4.0
499+
$file = $this->Attachments->getFile($id);
500+
$this->response->file($file['path']);
501+
// Return the response to prevent controller from trying to render
502+
// a view.
503+
return $this->response;
504+
498505
As shown in the above example, you must pass the file path to the method.
499506
CakePHP will send a proper content type header if it's a known file type listed
500507
in `Cake\\Http\\Reponse::$_mimeTypes`. You can add new types prior to calling
@@ -509,6 +516,12 @@ the browser by specifying the options::
509516
['download' => true, 'name' => 'foo']
510517
);
511518

519+
// Prior to 3.4.0
520+
$this->response->file(
521+
$file['path'],
522+
['download' => true, 'name' => 'foo']
523+
);
524+
512525
The supported options are:
513526

514527
name

0 commit comments

Comments
 (0)