By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,447 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

ZipArchive() (adding a directory)

P: n/a
Hello, group:

I'm able to successfully add files to a zip archive using php with the
following script, but I can't find anywhere I add directories, can
somebody help?
Thanks,

--TJ
<?php

$zip = new ZipArchive();
$filename = "./test112.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->addFromString("testfilephp2.txt" . time(), "#2 This is a test
string added as testfilephp2.txt.\n");
$zip->addFile($thisdir . "/too.php","/testfromfile.php");
$zip->close();
?>
Feb 29 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 29 Lut, 18:26, "techjoh...@gmail.com" <techjoh...@gmail.comwrote:
Hello, group:

I'm able to successfully add files to a zip archive using php with the
following script, but I can't find anywhere I add directories, can
somebody help?

Thanks,

--TJ

<?php

$zip = new ZipArchive();
$filename = "./test112.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->addFromString("testfilephp2.txt" . time(), "#2 This is a test
string added as testfilephp2.txt.\n");
$zip->addFile($thisdir . "/too.php","/testfromfile.php");
$zip->close();
?>
$zip->AddEmptyDirectory($_folderName)
if you wish to add file to this directory:
$zip->AddFile($_folderName .'/' . $_file);
Feb 29 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.