CodeIgniter Forums
force_download does not work in controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: force_download does not work in controller (/showthread.php?tid=64830)



force_download does not work in controller - cupboy - 03-30-2016

I can get this to work in a view but not in a controller. Why would that be?

For some odd reason someone posted something on another site (daniweb) where a poster claims to use it in a controller. Sure would like to see his code.


RE: force_download does not work in controller - josepostiga - 03-31-2016

Yes you can use it on a controller... In fact that's exactly where it should happen: https://codeigniter.com/user_guide/helpers/download_helper.html?highlight=force%20download#force_download

Remember to set that before any output is being done.