mostafatalebi Posted February 24, 2013 Share Posted February 24, 2013 Hello everybody I have made a download script that would send HTTP headers to the browser so to generate a download dialog box. But I need to redirect after the download window is shown. Like many sites on the internet. I cannot achieve this since it is a common problem. A redirection cannot happen as headers are already sent. What shall I do? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/274873-how-to-redirect-after-headers-are-sent/ Share on other sites More sharing options...
AyKay47 Posted February 24, 2013 Share Posted February 24, 2013 Restructure your code (recommended) or send the output before the header to the output buffer. Quote Link to comment https://forums.phpfreaks.com/topic/274873-how-to-redirect-after-headers-are-sent/#findComment-1414532 Share on other sites More sharing options...
requinix Posted February 24, 2013 Share Posted February 24, 2013 You can't header redirect and trigger a download at the same time. You could redirect to the page which then redirects to the download (and thus won't take the user away from that page). Other options depend on the purpose of the pages and the download. Quote Link to comment https://forums.phpfreaks.com/topic/274873-how-to-redirect-after-headers-are-sent/#findComment-1414539 Share on other sites More sharing options...
mostafatalebi Posted February 24, 2013 Author Share Posted February 24, 2013 Ahan this is a nice solution. To delay the download after the redirected page. I like it... thanks Quote Link to comment https://forums.phpfreaks.com/topic/274873-how-to-redirect-after-headers-are-sent/#findComment-1414653 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.