title: Downloading files which were uploaded to local folder in yii
body: <p>I've created an upload file page in Yii which successfully saves in both database and local folder and I've been researching on how to download this file and I've come across <a href="http://www.yiiframework.com/wiki/95/saving-files-to-a-blob-field-in-the-database/" rel="nofollow">this</a> and tried to follow it. </p>
  
  <p>In my model, I added this to the rules: </p>
  
  <pre><code>array('location', 'file', 'types'=&gt;'jpg,jpeg, png, doc,docx,xls,xlsx,pdf',
                    'maxSize'=&gt;1024 * 1024 * 3, // 3MB
                    'tooLarge'=&gt;'The file was larger than 3MB. Please upload a smaller file.',
                     'allowEmpty' =&gt; true),    
          );
  </code></pre>
  
  <p>My controller looks like this:</p>
  
  <pre><code>public function actionDisplaySavedImage()
  {
      $model=$this-&gt;loadModel($_GET['id']);
  
      header('Pragma: public');
      header('Expires: 0');
      header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
      header('Content-Transfer-Encoding: binary');
      header('Content-Disposition: attachment; filename='.$model-&gt;location);
  
          echo $model-&gt;location;
  }
  </code></pre>
  
  <p>and my view: </p>
  
  <pre><code>&lt;?php echo CHtml::link('Download Here',array('displaySavedImage','id'=&gt;$model-&gt;primaryKey)); ?&gt;
  </code></pre>
  
  <p>I could download the file, but when I open it, its a messed up file type. </p>
  
  <p>Like for example if I download an image, the windows photo viewer would appear but it would display a text saying "file type not supported" or something like that. </p>
  
  <p>Same is through if I try in different file types like .docx. Microsoft word would say that it is not supported.</p>
  
  <p>Please help</p>