groston Posted June 10, 2022 Share Posted June 10, 2022 Not sure what is going on, please help me. I have written a PHP file that generates a CSV file that is drawn from a MySQL database. This works just fine because I used this https://stackoverflow.com/questions/15769732/write-to-php-output-buffer-and-then-download-csv-from-buffer as a guideline. The problem is this: After the CSV file is downloaded, I want the site to go to another page. Using the code in the reply from DigiLive on 12 Jan 2016 as the basis, after the line ob_end_flush(); I have the lines echo "<script type='text/javascript'> document.location = 'OtherPage.php'; </script>"; exit; These lines work perfectly elsewhere, but here they do nothing. What am I missing? Quote Link to comment https://forums.phpfreaks.com/topic/314913-what-am-i-missing/ Share on other sites More sharing options...
ginerjm Posted June 10, 2022 Share Posted June 10, 2022 Showing us 1 line of code and asking for help is kind of impossible. Quote Link to comment https://forums.phpfreaks.com/topic/314913-what-am-i-missing/#findComment-1597189 Share on other sites More sharing options...
mac_gyver Posted June 10, 2022 Share Posted June 10, 2022 29 minutes ago, groston said: I have the lines 29 minutes ago, groston said: but here they do nothing actually, they are being appended to the end of the downloaded file. if you open the downloaded file in your programming editor, you should see that output. in the 'other' cases where you may have used those lines of code and they worked, you weren't downloading files, where you? the response that the web server outputs for a downloaded file - the http headers, followed by the file contents, can only be those two things. short-answer: you cannot redirect after the file download. if you do a web search on this, you will find that you first goto the desired final page, then use javascript on that page to make a http(s) request to the download link. Quote Link to comment https://forums.phpfreaks.com/topic/314913-what-am-i-missing/#findComment-1597190 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.