blob: e19ad1a2e04884b5af5ca6421bc0aa30ac8677ea [file] [log] [blame]
adminc167f2c2006-10-02 02:47:59 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html>
3<head>
4
Derek Allardd2df9bc2007-04-15 17:41:17 +00005<title>CodeIgniter User Guide</title>
adminc167f2c2006-10-02 02:47:59 +00006
7<style type='text/css' media='all'>@import url('../userguide.css');</style>
8<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
9
10<script type="text/javascript" src="../nav/nav.js"></script>
11<script type="text/javascript" src="../nav/prototype.lite.js"></script>
12<script type="text/javascript" src="../nav/moo.fx.js"></script>
13<script type="text/javascript">
14window.onload = function() {
admine334c472006-10-21 19:44:22 +000015 myHeight = new fx.Height('nav', {duration: 400});
adminc167f2c2006-10-02 02:47:59 +000016 myHeight.hide();
17}
18</script>
19
20<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
21<meta http-equiv='expires' content='-1' />
22<meta http-equiv= 'pragma' content='no-cache' />
23<meta name='robots' content='all' />
24<meta name='author' content='Rick Ellis' />
Derek Allardd2df9bc2007-04-15 17:41:17 +000025<meta name='description' content='CodeIgniter User Guide' />
adminc167f2c2006-10-02 02:47:59 +000026
27</head>
28<body>
29
30<!-- START NAVIGATION -->
31<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
32<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
33<div id="masthead">
34<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
35<tr>
Derek Allard60ca9b72007-07-12 19:53:27 +000036<td><h1>CodeIgniter User Guide Version 1.5.4</h1></td>
adminc0d5d522006-10-30 19:40:35 +000037<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
adminc167f2c2006-10-02 02:47:59 +000038</tr>
39</table>
40</div>
41<!-- END NAVIGATION -->
42
43
44<!-- START BREADCRUMB -->
45
46<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
47<tr>
48<td id="breadcrumb">
Derek Allardd2df9bc2007-04-15 17:41:17 +000049<a href="http://www.codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
adminc167f2c2006-10-02 02:47:59 +000050<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
51Download Helper
52</td>
Derek Allardbc030912007-06-24 18:25:29 +000053<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
adminc167f2c2006-10-02 02:47:59 +000054</tr>
55</table>
56<!-- END BREADCRUMB -->
57
58<br clear="all" />
59
60
61<!-- START CONTENT -->
62<div id="content">
63
64
65<h1>Download Helper</h1>
66
admin3cad41e2006-10-02 03:21:46 +000067<p>The Download Helper lets you download data to your desktop.</p>
adminc167f2c2006-10-02 02:47:59 +000068
69
70<h2>Loading this Helper</h2>
71
72<p>This helper is loaded using the following code:</p>
73<code>$this->load->helper('download');</code>
74
75<p>The following functions are available:</p>
76
77<h2>force_download('<var>filename</var>', '<var>data</var>')</h2>
78
admine334c472006-10-21 19:44:22 +000079<p>Generates server headers which force data to be downloaded to your desktop. Useful with file downloads.
adminc167f2c2006-10-02 02:47:59 +000080The first parameter is the <strong>name you want the downloaded file to be named</strong>, the second parameter is the file data.
81Example:</p>
82
83<code>
84$data = 'Here is some text!';<br />
85$name = 'mytext.txt';<br />
86<br />
87force_download($name, $data);
88</code>
89
90<p>If you want to download an existing file from your server you'll need to read the file into a string:</p>
91
92<code>
93$data = file_get_contents("/path/to/photo.jpg"); // Read the file's contents<br />
94$name = 'myphoto.jpg';<br />
95<br />
96force_download($name, $data);
97</code>
98
99
100
101
102</div>
103<!-- END CONTENT -->
104
105
106<div id="footer">
107<p>
108Previous Topic:&nbsp;&nbsp;<a href="directory_helper.html">Directory Helper</a>
109&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
110<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
111<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
112Next Topic:&nbsp;&nbsp;<a href="file_helper.html">File Helper</a>
Derek Allardc6441282007-07-04 23:54:32 +0000113</p>
Derek Allardd2df9bc2007-04-15 17:41:17 +0000114<p><a href="http://www.codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2007 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
adminc167f2c2006-10-02 02:47:59 +0000115</div>
116
117</body>
118</html>