note 12128 deleted from function.header by jimw
| From: | jimw@php.net | Date: | Wed, 31 Oct 2001 21:53:26 +0000 |
| Subject: | note 12128 deleted from function.header by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-19767@lists.php.net to get a copy of this message | ||
At a site i needed a function that enabled the clients to pick the files that where put in the zip
and download it, here is what i come up with, it shows how the header works....
<?php
// Vars
$tempdir = "/home/elze/www/tempdir/";
$downloadname = md5($REMOTE_ADDR).".zip";
$inzip = "/home/elze/www/chat/*";
// Generate randomstring
$md5_deel1 = md5($REMOTE_ADDR);
srand((double)microtime()*1000000);
$md5_deel2 = md5(rand(0,9999999));
$zipname = $tempdir.$md5_deel1."_1_".$md5_deel2.".zip";
// Het is een download he
header("Content-Type: application/download\n");
header("Content-Disposition: filename=\"$downloadname\"");
header("Content-Transfer-Encoding: binary");
// Download can take a while... no max time limit
set_time_limit(0);
// make zip
exec("zip -j -9 -v -X $zipname $inzip");
// zipfile open-send-close
$fn=fopen($zipname , "r");
fpassthru($fn);
fclose($fn);
// rm temp file
exec("rm $zipnaam");
?>