I have a very basic question illustrated by the code snippet below. This is the relevant part of a much bigger program in which I wish to download a zip file. The code as shown, with the comments in place, produce the expected browser output "Download the file now."
When I un-comment the code, the zip file is correctly downloaded to my browser!
However, the browser output is not produced. How do I regain control? I would like for the user to then have other options. (By the way, un-commenting the single "Content-disposition" line is sufficient to cause the loss of control.)
I have tried including the code, putting it in a function, many possible combinations of ob_start, ob_end flush, etc., all to no avail. I am sure I am overlooking something very fundamental and would appreciate some suggestions.
Thanks.
<?php
$sZipFN = 'file.zip';
// header("Content-type: application/zip");
// header("Content-disposition: attachment; filename=$sZipFN");
// readfile($sZipFN);
$sMsg = "Download the file now.";
?>
<html>
<body>
<p> <?php echo $sMsg; ?> </p>
</body>
</html>