how to force download

Showing 1-5 of 5 messages
how to force download bingo 10/2/07 4:57 AM

In my view, there is an option to download data in a xml format. The
user clicks on the submits a form and a controller method is executed.
The controller calls a file utility (in the vendor folder) that sets
the header and sets the file content for download and at the script
calls die(); Although everything seems to be right, I am not able
force download. When the user clicks on the download link, the browser
goes to the controller url and then just dies out.

Can anyone shed a light on how to force download in CakePHP. i assume
I am messing up with header content


Re: how to force download Grant Cox 10/2/07 5:01 AM
I have the following:

if ( $extension == 'xls' ){
        header("Content-type: application/");
        header("Content-Disposition: attachment; filename=\"$excel_filename
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
        header("Pragma: public");

        echo $excel_file_data;

Re: how to force download bingo 10/2/07 5:46 AM
hi Grant,

Is your code in controller ?. If I put the code in the controller then
my download works. But lot of my controller require download ability,
so I am trying to create an independent download class in vendors
folder. Do you think making it a helper will be better ?


> > Ritesh- Hide quoted text -
> - Show quoted text -

Re: how to force download 10/2/07 5:49 AM
you would probably do better with a component if you're using 1.2
Re: how to force download bingo 10/2/07 9:17 AM

Thanks for the suggestion. I will try you think just putting
Grant's code in a component will work..I will give it shot..


On Oct 2, 8:49 am, ""