I got a script like this
<?php
if (file_exists("./foo.txt")) {
header("Content-type: application/force-download");
header("Content-length: ".filesize("./foo.txt"));
header('Content-Disposition: attachment; filename="foo.txt"');
readfile('./foo.txt');
}
print "HEY!";
?>
and I want the "Hey" to be written to the page after the forced download, how is that possible?
I see download pages that are like "If your download does not start automatically click here", so it's content and the download? The hey
in my example is included in the text file, so it doesn't work.
This would only be possible with a multipart message. But unfortunately there are not many browser that support multipart messages in HTTP (I think Opera is the only one).
That’s why it’s common practice to send the download page with a meta refresh redirect to have both a textual message and a download action (although it’s in the opposite order).
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