title: Render view after image file is downloaded in Yii
body: <pre><code>public function actionViewDownload(){
  
      // some in internal processing php commands (no echo)
  
      exec($command); // command to be executed compulsary
  
      $file = "/images/sample.jpg"; // some images file
      if (file_exists($file)) {
          header('Content-Description: File Transfer');
          header('Content-Type: application/octet-stream');
          header('Content-Disposition: attachment; filename='.basename($file));
          header('Content-Transfer-Encoding: binary');
          header('Expires: 0');
          header('Cache-Control: must-revalidate');
          header('Pragma: public');
          header('Content-Length: ' . filesize($file));
          readfile($file);
      }
      $this-&gt;render('view',array('data'=&gt;$data)); // render the other view of the controller after/during download.
  
  }
  </code></pre>
  
  <p><b>I need to execute a command, then download the image file and after or during downloading render, the view.</b><br>
  If I render the view before downloading it prompts "Header cannot be modified. Headers already sent"<br>
  and if I render the view after the download then view is now shown on browser but the file gets downloaded.<br>
  My question here is that how can I achieve three tasks : <b>execution of the command (this must be first), render and download.</b></p>