Anon E Mouse - 2009-11-12 01:06:56 -
In reply to message 3 from Attila Wind
That is brilliant Attila, thank you!
It took me a little while to figure out how to use it but it works perfectly, solves the memory problem you are a legend.
Here is an example page others can use to modify, to use Attila's updated version of this great class.
Thanks to Rochak too, for creating the class to begin with.
Example using Attila's version of the class:
<?php
set_time_limit(0);
include "conn_doc.php";
include_once("zipfile.inc.php");
while(list($key,$value)= each($_GET)){
$$key = $value; // this line does the actual creation and assignment of variables
}
echo("<html><head></head><body>");
echo('<font face="Verdana, Arial, Helvetica, sans-serif" color="#000066" size="3"> Zipping your files now, please be patient....<BR>');
flush();
$directoryToZip="./"; // This will zip file(s) in this present working directory
//$outputDir="/"; // The desired output directory. NOTE: leaving it that way made some weird msg unzipping
$outputDir="/yourfiles/"; // The desired output directory.
$createZipFile=new CreateZipFile;
$rand=(rand()%9999);
$zipName=$JobID."-".$rand.".zip";
$fd=fopen($zipName, "wb");
$createZipFile->ZipFile($fd);
$createZipFile->addDirectory($outputDir);
$sql = "SELECT * from Job WHERE JobID=".$JobID." ORDER BY IncludeInList DESC, Priority";
$ri = mysql_query($sql);
for ($count = 1; $row = mysql_fetch_row ($ri); ++$count)
{
$Movie=$row[20];
If ($Movie){
// Code to Zip a single file
$fileToZip=$Movie;
$createZipFile->addFile($directoryToZip.$fileToZip, $outputDir.$fileToZip);
echo("adding ".$fileToZip."<BR>");
flush();
} // end If Movie
} //finish the Job recordset For Loop
mysql_close ();
$createZipFile->close($fd);
echo("Successfully created file ready for downloading");
echo('<BR><BR><A HREF="'.$zipName.'"><font size=+2><B>Click here to Download the zip file</B></font></A>');
echo("</font></body></html>");
?>