Create ZIP via PHP in a specific directory
<p>I found this awesome code to create a ZIP file using PHP via this link <a href="http://stackoverflow.com/questions/3828385/compress-archive-folder-using-php-script">compress/archive folder using php script</a></p>

<pre><code>&lt;?php
// Config Vars 

$sourcefolder = "./"           ; // Default: "./" 
$zipfilename  = "myarchive.zip"; // Default: "myarchive.zip"
$timeout      = 5000           ; // Default: 5000

// instantate an iterator (before creating the zip archive, just
// in case the zip file is created inside the source folder)
// and traverse the directory to get the file list.
$dirlist = new RecursiveDirectoryIterator($sourcefolder);
$filelist = new RecursiveIteratorIterator($dirlist);

// set script timeout value 
ini_set('max_execution_time', $timeout);

// instantate object
$zip = new ZipArchive();

// create and open the archive 
if ($zip-&gt;open("$zipfilename", ZipArchive::CREATE) !== TRUE) {
    die ("Could not open archive");
}

// add each file in the file list to the archive
foreach ($filelist as $key=&gt;$value) {
    $zip-&gt;addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
}

// close the archive
$zip-&gt;close();
echo "Archive ". $zipfilename . " created successfully.";

// And provide download link ?&gt;
&lt;a href="http:&lt;?php echo $zipfilename;?&gt;" target="_blank"&gt;
Download &lt;?php echo $zipfilename?&gt;&lt;/a&gt; 
</code></pre>

<p>I would like to create the zip in a particular directory. </p>
