|  | Posted by Dahak on 10/20/07 18:57 
I may be having an attack of the stupids and my Google-foo isfailing me today, but I can't seem to get past this problem.
 
 
 I have a script that indexes a directory and provides the user
 with a simple interface to select files to download.
 
 Once they've made their selection and submitted the form, the form
 action reloads the page.
 
 On reload, the script checks for the presence of POST variables
 and, if not found, redisplays the previous form or, if found collects
 files for download.
 
 If this is the first request, the target files are collected into
 a ZIP file and saved to the server for reuse.
 
 Then the script serves the saved file to the user for download
 with the following code:
 
 ---
 
 header('Pragma: public');
 header('Content-type: application/zip');
 header('Content-length: ' . filesize($zipdir . '/' . $zipfilename));
 header('Content-Disposition: attachment;
 filename="'.$zipfilename.'"');
 
 //    readfile( $zipdir . '/' . $zipfilename );
 if ( ( $fp = fopen( $zipdir . '/' . $zipfilename, 'rb' ) ) === false )
 exit;
 @fpassthru( $fp );
 @fclose( $fp );
 
 ---
 
 This all works fine.  The commented out readfile() _also_ worked
 fine, but I've been trying to see how to get past my problem, which
 is:
 
 Once the file is sent to the output stream, the script seems to
 halt.
 
 I want to get the script to continue rendering a 'Thank you for
 downloading...'-type page, but nothing seems to happen after the
 readfile() or fpassthru().
 
 In practical terms, this is nothing more than an annoyance.  The
 end user gets the requested ZIP file, but nothing else can be done in
 the script.  (I have a 'busy' graphic that I unhide on form submission
 that I want to hide again upon completion.)
 
 
 What am I forgetting?  Is there something in the header man pages
 that I've missed?
 
 Other examples I've searched for online seem to imply that script
 execution should continue.
 
 
 Any thoughts would be appreciated.
 
 -Joe
  Navigation: [Reply to this message] |