Load page before download triggers ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Load page before download triggers ?

Post by MiniMonty »

Hi all,

I'm trying to build a page that triggers an automatic download of a zip file.
I'm using this:

Code: Select all

 
<?php
 
/////  TRIGGER THE DOWNLOAD
 
    $filename = "blahblah/bleetbleet.zip";
    header("Pragma: public"); // required
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private",false); // required for certain browsers 
    header("Content-Type: application/x-zip");
    header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".filesize($filename));
    readfile("$filename");  
    exit();
    ?>
 
 
Trouble is, I need to display a message to the user on the page and I can't seem to figure out how to.

How can I force the page (which is just text and basic graphics) to load before the download starts ?

(any other cool solutions much appreciated) !

Best wishes
Monty
Post Reply