I have problem with my PHP code:
header('Content-Disposition: attachment; filename="config.yml"');
header('Content-Type: text/plain');
header('Content-Length: '.strlen($file));
readfile($file);
File is downloaded well, but page will close instantly. Like downloading will start, and page will close. But I have in page also some else code, like html. I don't want to close page after downloading. Can you give me some advice ? Because I don't know, where can be mistake.
You cannot return both the file download and html or other content in the same response.
What you need to do is return the html first and within that have a request for the download. E.g.
<iframe width="1" height="1" frameborder="0" src="/downloadfile.php"></iframe>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With