Hi again,
 
After a clever question follows a dumb one: :-(
 
I am trying to pack a few resources from off the server, zip them together
(at this stage still storing in a tmp folder and afterwards deleting it
again) and make the freshly created zip file available to the user via a
'Save File' prompt. Now I have searched the archives a bit and have read the
suggestions in the extended chm version of the manual TWICE, but still, I
don't seem to be able to get rid of this one stupid problem:
 
The zip gets created fine, but when I readfile() it and pump it through the
headers it adds the whole html (which the server sent to the browser - not
the php code) and so corrupts the zip file. I have read about suggestions to
these issues, implemented these suggestion and still sit with it.
 
I am using Apache 1.3.20, PHP 4.3.2 and mySQL on a Windows stove. The
browsers I have tested this on was IE6 and Opera 7 . both acted the same
way. This got me thinking that: maybe I am doing something wrong . ;-)
 
So here is the method I am using to pack and send the stuff .
 
[code]
function PackAndSend( )
{
            include_once( realpath("classes/pclzip.lib.php") );
                                    
            $filePath = realpath( "tmp/zips/". substr( md5( $_GET["file"] ),
0, 5 ) .".zip" );
                                    
            $zip = new PclZip( $filePath );
            $zip->create( realpath("files/papers/$_GET[file]"),
"Resources/Docs ID [$_GET[file]]", "files/papers/" );
                        
            $fz = filesize( $filePath );
            $mime_type = "application/zip";
                                    
            header('Pragma: public'); // IE specific
            header('Cache-Control: private');
            header('Cache-Control: no-cache, must-revalidate');
            header('Accept-Ranges: bytes');
            header('Content-Length: ' . $fz);
            header('Content-Type: $mime_type');
            header('Content-Disposition: attachment;
filename=Resources.zip');
                                    
            @readfile( $filePath );
            unlink( $filePath );
            $GLOBALS['COPE_LOG']->devLog();
}
[/code]
 
The headers sequence I have tried with many others . all did not do anything
different.]
 
Help would be appreciated.
 
Thomas

Reply via email to