[UPHPU] Dir to zip

Trevyn Meyer trevyn at esourcehome.com
Tue Jan 22 21:05:25 MST 2008


Here is what I put together.  Free grabs.
http://esourcehome.com/download/

Trevyn

Trevyn Meyer wrote:
 > 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>
 >
 > _______________________________________________
 >
 > UPHPU mailing list
 > UPHPU at uphpu.org
 > http://uphpu.org/mailman/listinfo/uphpu
 > IRC: #uphpu on irc.freenode.net
 >



More information about the UPHPU mailing list