diff options
author | Andrey Andreev <narf@devilix.net> | 2016-11-01 15:12:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-01 15:12:34 +0100 |
commit | c6737d2110fd9c9ccc79c5407c5ae3e11b24422d (patch) | |
tree | 8fc462d871a9922853a63cbb9ba9206a16b34554 /user_guide_src | |
parent | 52d264d960aded1620ae8505e2935de12b0209e9 (diff) | |
parent | 49407be71a80d67151a296be25fff2468c68ab55 (diff) |
Merge pull request #4891 from gxgpet/develop_31102016
Allow existing file rename-for-download in force_download() helper
Diffstat (limited to 'user_guide_src')
-rw-r--r-- | user_guide_src/source/helpers/download_helper.rst | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/user_guide_src/source/helpers/download_helper.rst b/user_guide_src/source/helpers/download_helper.rst index 1a4065073..e11d92a14 100644 --- a/user_guide_src/source/helpers/download_helper.rst +++ b/user_guide_src/source/helpers/download_helper.rst @@ -26,7 +26,7 @@ The following functions are available: .. php:function:: force_download([$filename = ''[, $data = ''[, $set_mime = FALSE]]]) - :param string $filename: Filename + :param mixed $filename: Filename :param mixed $data: File contents :param bool $set_mime: Whether to try to send the actual MIME type :rtype: void @@ -37,8 +37,11 @@ The following functions are available: file data. If you set the second parameter to NULL and ``$filename`` is an existing, readable - file path, then its content will be read instead. - + file path, then its content will be read instead. You may also set ``$filename`` + as an associative array with a single element, where the key of that element would be + the local file you are trying to read and where the value is the name of the downloadable + file that will be sent to browser. An example of this is provided below. + If you set the third parameter to boolean TRUE, then the actual file MIME type (based on the filename extension) will be sent, so that if your browser has a handler for that type - it can use it. @@ -53,4 +56,10 @@ The following functions are available: do the following:: // Contents of photo.jpg will be automatically read - force_download('/path/to/photo.jpg', NULL);
\ No newline at end of file + force_download('/path/to/photo.jpg', NULL); + + If you want to download an existing file from your server, but change the name + of the actual file sent to browser, you will need this:: + + // Contents of photo.jpg will be automatically read and sent as my-photo.jpg + force_download(array('/path/to/photo.jpg' => 'my-photo.jpg'), NULL);
\ No newline at end of file |