I created a component for this - based on code I found in Textpattern
CMS. Basically you pass your data (string) to the component, it
creates a temporary file in the cache and feeds the contents to the
user as a stream. Maybe it works for you:

<code><pre>
function download($data = null, $filename = 'download', $extension =
'tab') {
        if (!$data) return;

        $path = 'persistent' . DS . $filename . '.' . $extension;

        cache($path, $data);

        $fullpath = CACHE . $path;

        if (!is_file($fullpath)) {
                debug("Error Download: unable to create cache at $fullpath");
                die;
        }

        $filesize = filesize($fullpath);
        $sent = 0;

        header('Content-Description: File Download');
        header('Content-Type: application/octet-stream');
        header('Content-Length: ' . $filesize);
        header('Content-Disposition: attachment; filename="' .
basename($path) . '"');

        @ini_set("zlib.output_compression", "Off");
        @set_time_limit(0);
        @ignore_user_abort(true);

        if ($file = fopen($fullpath, 'rb')) {
                while(!feof($file) && (connection_status() == 0)) {
                        echo fread($file, 1024 * 64);
                        $sent += (1024 * 64);
                        flush();
                }
                fclose($file);
        }

        die;
}
</pre></code>

On May 6, 11:50 pm, Anil <[EMAIL PROTECTED]> wrote:
> Hi,
> I need the help to implement code for downloading files. If you know
> how to do that, please do me the favour.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to