Dude, that´s why i used the variables $name and $path, because it´s 
dynamic, and you should use at controller´s action, i will give an example:

//Assuming that the folders structure are exactly the same it cames from 
CakePHP´s server.
class DownloadsController extends AppController{    
    public function download($name){
        //First check if user is logged in or any check you want to do 
before it downloads...
        $path=APP.WEBROOT_DIR.DS.'files'.DS.$name;
        header("Content-Type: application/octet-stream");
        header("Content-Transfer-Encoding: Binary");
        header('Content-disposition: attachment; filename="'.$name.'"'); 
        echo file_get_contents($path);
    }    
}

Them if you access www.yoursite.com/downloads/download/file.extension it 
will download the file.extension, and the system will get this file at 
/app/webroot/files dir
Or if you navigate to www.yoursite.com/downloads/download/mypicture.jpg it 
will force the download of mypicture.jpg, wich should be at 
/app/webroot/files dir

***
If the download should start ONLY if the user is logged-in or if user 
should do some action, do not use the webroot´s directory to store the 
files, use the app directory or any directory not accessible throught 
browser
This is just an example to understand how to force a download in CakePHP, 
it´s just adjust for your use.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to