I have the following in a layout file;
<?php
$Filename = "TheEvent.vcs";
header("Content-Type: application/force-download");
header("Content-Disposition: inline; filename=$Filename");
echo $content_for_layout;
?>
Now in the controller I have this layout defined and it is working as I can see the text of my ical file. The only problem is the download isn’t being forced on the client.
I followed the following guide though I am using cakePHP 2.0
http://labs.iamkoa.net/2007/09/07/create-downloadable-ical-events-via-cake/
Thanks
Ash
you can use the new 2.0 request features to download right away:
http://www.dereuromark.de/2011/11/21/serving-views-as-files-in-cake2/
You can use file() and the other documented ways of serving files – see http://book.cakephp.org/2.0/en/controllers/request-response.html#cakeresponse