I want the user be forced to download a file, then be redirected to another page. There was a lot more code, but in debugging this issue I have cut everything down to the following snippet(assume $link has been defined):
ob_start();
header("Refresh: 0; URL=".$link);
header("Content-Disposition: attachment; filename='test.doc'");
ob_end_flush();
exit;
This works in Firefox, but not in Chrome. If I comment out the content-disposition header, the redirect work will work in Chrome. As of right now, this makes Chrome force the download, but it will not execute the redirect. In Firefox, the download is forced, and the page redirects. Which is the desired effect. I have tried doing this with and without the ob_start/ob_end_flush statements. I have tried using die() instead of exit. I have tried different syntaxes for the same header statements.
Unfortunately, using header("Location: $link") will not work for this situation, because it will not allow the download to be executed. This is true in Firefox and Chrome.
I'm hoping it's something dumb that I'm missing. But any insight would be greatly appreciated.
Please let me know if I can offer clarification on this issue.