title: Download File in Yii
body: <p>I am trying to write a script in Yii for downloading files from the server.</p>
  
  <p>The files are located in webroot of the Yii project, </p>
  
  <p>but I got every time file not exist error, could anyone see where is wrong: </p>
  
  <pre><code>public function actionDownload($id) {
      $audio = Audio::model()-&gt;findByPk($id);
      $file =  Yii::getPathOfAlias('webroot') . $audio-&gt;path;
      if (file_exists($file)) {
          header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
          header('Content-Description: File Transfer');
          header('Content-Type: application/octet-stream');
          header('Content-Disposition: attachment; filename=' . $audio-&gt;path);
          header('Content-Length: ' . filesize($audio-&gt;path));
          $audio-&gt;downloaded = $audio-&gt;downloaded + 1;
          $audio-&gt;save();
      }else{
          echo "file not exist: ".$file;            
      }
      exit;
  }
  </code></pre>
  
  <p>error I got is:</p>
  
  <pre><code>file not exist: /var/www/vhosts/ikhwanbiz.org/httpdocs/userfiles/reklames/media/deneme/sen%20dep%20olmisem.mp3
  </code></pre>
  
  <p>Thanks</p>
  
  <p>Regards</p>
  
  <p>Bili</p>