[UPHPU] Dir to zip

Trevyn Meyer trevyn at esourcehome.com
Tue Jan 22 15:01:58 MST 2008


I am starting to find a lot of ways I could use a recursive zip archiver 
for php.  Point the script to a dir, it zips up the files and preserves 
the directory structure.  And offers it for download.

This is a start, but didn't know if anyone wanted to help put the 
recursive and directories feature in it.

Here is where I stared my research:

http://us3.php.net/manual/en/ref.zip.php

I didn't see one that wrapped it up nicely.

Trevyn


<?php

$zip = new ZipArchive();
$filename = "./test_zip.zip";



if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
    exit("cannot open <$filename>\n");
}

//$zip->addFromString("testfilephp.txt" . time(), "#1 This is a test 
string added as testfilephp.txt.\n");
$zip->addFile($thisdir . "/too.php","/testfromfile.php");
echo "numfiles: " . $zip->numFiles . "br";
echo "status:" . $zip->status . "br";
$zip->close();
?>

<a href="test_zip.zip">Download</a>


More information about the UPHPU mailing list