diff options
author | George Petculescu <gxgpet@gmail.com> | 2016-10-31 00:38:18 +0100 |
---|---|---|
committer | George Petculescu <gxgpet@gmail.com> | 2016-10-31 00:38:18 +0100 |
commit | c867754cbb2260efeaa25ff9c339989807e8c713 (patch) | |
tree | ec9246db1c7366237c96771cde0173659fcd0b23 /user_guide_src/source | |
parent | 67b40a561111a5a65faa245cd4c575e8d945cfb8 (diff) |
download helper should be able to offer a download by reading a local file and also a custom destination filename.
Diffstat (limited to 'user_guide_src/source')
-rw-r--r-- | user_guide_src/source/helpers/download_helper.rst | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/user_guide_src/source/helpers/download_helper.rst b/user_guide_src/source/helpers/download_helper.rst index 1a4065073..83182a256 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,7 +37,9 @@ 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 array containing a single entry, the key being the existing, readable file path + and the value as the downloading file name. 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 @@ -53,4 +55,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 |