title: Download a recently created file
body: <p>I have a function which currently creates a file and stores it in a folder on my server.</p>
  
  <p>I want to continue doing this but I also want it to force to download.</p>
  
  <p>This is the function:</p>
  
  <pre><code>// Generates a filename and writes a CSV with a timestamped name
  function putAsCSV($data_list,$account_name,$timeframe){
      $date =  date('d-m-Y-h-i-A');
      $filename = $timeframe.'-'.$account_name.'-'.$date;
      $fp = fopen('../exports/'.$filename.'.csv', 'w');
      foreach ($data_list as $fields) {
          fputcsv($fp, $fields);
      }
      fclose($fp);
  }
  </code></pre>
  
  <p>How can I make it download this file as well as storing it?</p>
  
  <p>Do I need to store it in some sort of temporary file?</p>
  
  <p>How can I ensure it doesn't open in the browser and actually downloads?</p>