I wonder if anyone can help me out with this. I am sending the user to a download page where when they click on the download button the file is downloaded and then I want the user redirected after the file download to a confirmation page.
My download processing page is as follows:
[PHP]<?php
$mytalk = $_GET['varrqust'];
if($_GET['varrqust'] == "1"):
$mytalk = 'Talk 1';
$talksize = 3Mb';
$talkpath = 'talk1.pdf';
elseif($_GET['varrqust'] == "2"):
$mytalk = 'Talk 2';
$talksize = '3Mb';
$talkpath = 'talk2.pdf';
elseif($_GET['varrqust'] == "3"):
$mytalk = 'Talk 3';
$talksize = '3Mb';
$talkpath = 'talk3.pdf';
endif;
$path = $talkpath;
$file = basename($path);
$size = filesize($path);
//do download
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$file");
header("Content-Transfer-Encoding: binary");
header("Content-Length: $size");
@readfile($path);
header("Location: sbx_dwnldthx.php?varrqust=$varrqust"); /* Redirect browser */
exit();
?>[/PHP]
In this instance the file is downloaded as expected but the user doesn't get redirected.
If I change the order of the last few lines of code as follows:
[PHP]<?php
..........
header("Location: sbx_dwnldthx.php?varrqust=$varrqust"); /* Redirect browser */
@readfile($path);
exit();
?>[/PHP]
The user gets redirected as required but the file doesn't get downloaded!
Can someone please explain where I am going wrong.
Thanks in advance.