You need to let your download function know which file to download. You can do 
this by passing the name of the file into the function:

<li><?php echo $html->link('Game 1',array('action'=>'download', 'filename1')); 
?></li>
<li><?php echo $html->link('Game 2',array('action'=>'download', 'filename2')); 
?></li>


function download ($filename = '')
        {
       $this->view = 'Media';
       $params = array(
             'id' => $filename,
             'name' => 'example',
             'download' => true,
             'extension' => 'zip',
             'path' => APP . 'gamefiles' . DS);
      $this->set($params);
   }

If you don't want to reveal the name of the file, you could store them in a 
table and pass in the id of the record instead of the filename, then in your 
download function do a find to get the name first.

Jeremy Burns
Class Outfit

[email protected]
http://www.classoutfit.com

On 5 Feb 2011, at 10:16, newguy wrote:

> I have a display page with follwoing 4 links:
> 
> <p>Select the game to download</p>
> <ul>
> <li><?php echo $html->link('Game 1',array('action'=>'download')); ?></
> li>
> <li><?php echo $html->link('Game 2',array('action'=>'download1')); ?></
> li>
> <li><?php echo $html->link('Game 3',array('action'=>'download1')); ?></
> li>
> <li>Game 4</li>
> </ul>
> 
> On clicking each link a different file should be downloaded.
> 
> I am using Media View to dlownload file placed on my disk but since
> the file name is hardcoded I am able to download only one file through
> the download fucntion, I want to know that is it possible that I just
> pass the name of the file to be downloaded(depending on the link
> clicked) to the download function of media view and the respective
> file is downloaded(extension of all files is zip).
> 
> Heres my controller code:
> 
> function download ()
>         {
>        $this->view = 'Media';
>        $params = array(
>              'id' => 'example.zip,
>              'name' => 'example',
>              'download' => true,
>              'extension' => 'zip',
>              'path' => APP . 'gamefiles' . DS);
>       $this->set($params);
>    }
> 
> Guys am new here so please help me witha little more explanation than
> usual.
> 
> Thanks
> 
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org 
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
> 
> 
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to