Redirect any page after file download in php
<p>My code is:</p>

<pre><code>readfile('cls_ref.csv');
fclose($fp);
$file_type   = 'octet-stream';
$file_name   = "cls_ref_" . date('m-d-Y H:i');
$file_ending = "csv";
header("Content-Type: application/$file_type; charset=utf-8");
header("Content-Disposition: attachment; filename=$file_name.$file_ending");
header("Pragma: no-cache");
header("Expires: 0");
header("Location:index.php");
</code></pre>

<p>I want to redirect after download to <code>index.php</code> but it is redirect before download.</p>

<p>I write a code <code>header("Location:index.php");</code> at end of the file but it is redirect before
download the file.</p>

<p>Any solution for that?</p>
