how to force download

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

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

Regards,
Ritesh

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

if ( $extension == 'xls' ){
        header("Content-type: application/vnd.ms-excel");
        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;
}
@flush();
@ob_end_flush();
exit();

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 ?


Thanks

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

Re: how to force download simonell...@googlemail.com 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
hi

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

Thanks
Ritesh

On Oct 2, 8:49 am, "simonellistonb...@googlemail.com"