From 48a8675c3a50beba5a22080ea11050287b5866bb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 8 Nov 2012 15:16:34 +0200 Subject: Polish docs for Array, CAPTCHA, Cookie, Date, Directory and Download helpers --- user_guide_src/source/helpers/download_helper.rst | 32 ++++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'user_guide_src/source/helpers/download_helper.rst') diff --git a/user_guide_src/source/helpers/download_helper.rst b/user_guide_src/source/helpers/download_helper.rst index e6094dc6b..1e9ec21ea 100644 --- a/user_guide_src/source/helpers/download_helper.rst +++ b/user_guide_src/source/helpers/download_helper.rst @@ -9,34 +9,40 @@ The Download Helper lets you download data to your desktop. Loading this Helper =================== -This helper is loaded using the following code - -:: +This helper is loaded using the following code:: $this->load->helper('download'); The following functions are available: -force_download('filename', 'data') -================================== +force_download() +================ + +.. php:function:: force_download($filename = '', $data = '', $set_mime = FALSE) + + :param string $filename: Filename + :param string $data: File contents + :param bool $set_mime: Whether to try to send the actual MIME type + :returns: void Generates server headers which force data to be downloaded to your desktop. Useful with file downloads. The first parameter is the **name you want the downloaded file to be named**, the second parameter is the -file data. Example +file data. + +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. -:: +Example:: $data = 'Here is some text!'; $name = 'mytext.txt'; force_download($name, $data); If you want to download an existing file from your server you'll need to -read the file into a string +read the file into a string:: -:: - - $data = file_get_contents("/path/to/photo.jpg"); // Read the file's contents + $data = file_get_contents('/path/to/photo.jpg'); // Read the file's contents $name = 'myphoto.jpg'; - force_download($name, $data); - + force_download($name, $data); \ No newline at end of file -- cgit v1.2.3-24-g4f1b