title: Yii Download File from CGridView
body: <p>I have a form on Yii that allows people to upload a variety of different file formats. When the file is uploaded, I have a Db that adds an entry for that file:</p>
  
  <pre><code>+--------------+---------------+-------------+---------------+
  |   id         |     name      |    acc_id   | date_uploaded |
  +--------------+---------------+-------------+---------------+
  |   1          |     test.png  |  100         | 2014-05-20   |
  +--------------+---------------+-------------+---------------+
  </code></pre>
  
  <p>The files are held on the root folder /files/uploaded and are saved using the <code>id</code> ie 1-test.png.</p>
  
  <p>I can then on an account show the uploaded files, by displaying those that match the account <code>id</code> in a cgridview.</p>
  
  <p>The issue I am having is that I need a download button. I have tried a few things and do not seem to be able to get this to work. The closest I have got is using the following code</p>
  
  <pre><code>array(
          'class'=&gt;'CLinkColumn',
          'header'=&gt;'Download',
          'label'=&gt;'Download',
          //'url' =&gt; '/files/uploaded/$data-&gt;id',
          'htmlOptions'=&gt;array('width'=&gt;'18'),
      ),
  </code></pre>
  
  <p>However the <code>$data</code> variable does not seem to be working here, I believe this is to do with the CLinkColumn. If I try UrlExpression for example, it always add index.php and my file is never resolved. Can someone point me in the right direction of how to solve this and also the best method to store and call these files.</p>
  
  <p>Many Thanks</p>