blob: e6094dc6be22fe45e2eec030d423bc56a4ea40f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
###############
Download Helper
###############
The Download Helper lets you download data to your desktop.
.. contents:: Page Contents
Loading this Helper
===================
This helper is loaded using the following code
::
$this->load->helper('download');
The following functions are available:
force_download('filename', 'data')
==================================
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
::
$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
::
$data = file_get_contents("/path/to/photo.jpg"); // Read the file's contents
$name = 'myphoto.jpg';
force_download($name, $data);
|