Hi there,
 
I am (again) trying to download a file from off the server and force it to
use the download dialog box. I have been trying pclzip.lib for compression
and used my own headers  (as depicted below). This version did zip nicely
and the files were intact in the tmp folder. But once I used the headers it
mixed the html code into the resulting zip file. I know I must not mix the
my html and the zip data . but why is this happening?
Then I have used PEAR's HTTP_DOWNLOAD. The result: the exact same problem.
HTML is mixed with the data coming from the headers.
 
We have used ob_start() ( with gzip handlers), which I have taken out now,
but the problem is still the same. So that cannot be the problem? Why on
earth does it mix the html with the data? I do not include any html files.
 
Below are the two variations. The function 'PackAndSend' is called before
any output has taken place.
 
[1]
// The headers //
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=$name" );
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
 
// The zipping //
$mime = mime_content_type("files/papers/$_GET[file]");
$filePath = realpath( "tmp/zips/". substr( md5( $_GET["file"] ), 0, 5 )
.".zip" );
 
$zip = new PclZip( $filePath );
$zip->create( "files/papers/$_GET[file]", "[ICT2005] Review Resources/Paper
ID [$_GET[file]]", "files/papers/$_GET[file]" );
 
// reading the resulting zip file //
@readfile( "files/papers/$_GET[file]" );
// destroying the copy //
unlink( $filePath );
 
[2]
require_once( 'HTTP/Download.php' );
                                    
$dl = &new HTTP_Download();
$dl->setFile('files/papers/'.$_GET['file']);
$dl->setContentDisposition(HTTP_DOWNLOAD_ATTACHMENT, $_GET['file']);
$dl->setContentType('application/x-gzip');
$dl->send();
 
Also, if I use the headers (as above in [1]) with a normal file, it has got
the neck of working fine on my machine (XP Pro, IE6, Apache 1.3, PHP4.3.2)
but not on the server (Debian, IE6, Apache 1.3, PHP4.02).
 
Any suggestions?
 
Thomas

Reply via email to