CodeIgniter Forums
File helper() write file? Download prompt! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: File helper() write file? Download prompt! (/showthread.php?tid=44451)



File helper() write file? Download prompt! - El Forum - 08-15-2011

[eluser]brucebat[/eluser]
Hi all,

I have been playing around with the file helper class.

Basically I want a query result in a csv file to be downloaded by the user, NOT written to a folder somewhere.

So this is what happens:

-Enters query (works)
-Query result in CSV (works)
-Query result in file, download prompt for user to download .csv file (not functioning)

This is what I have

Code:
//csv data
$csv

write_file('', $csv);

I had a look at the File Helper but no code relevant to what I am trying to achieve.

Thanks for your time Smile


File helper() write file? Download prompt! - El Forum - 08-15-2011

[eluser]Near[/eluser]
http://ellislab.com/forums/viewthread/196559/


File helper() write file? Download prompt! - El Forum - 08-15-2011

[eluser]Near[/eluser]
Click here

hope it works for you too... :-)


File helper() write file? Download prompt! - El Forum - 08-15-2011

[eluser]bubbafoley[/eluser]
use the download helper

Code:
$this->load->helper('download');

$data = 'Here is some text!';
$name = 'mytext.txt';

force_download($name, $data);

http://ellislab.com/codeigniter/user-guide/helpers/download_helper.html


File helper() write file? Download prompt! - El Forum - 08-15-2011

[eluser]brucebat[/eluser]
Thanks bubbofoley this was what I wanted to hear ! Smile