开发者

download a folder using php

开发者 https://www.devze.com 2023-02-20 14:38 出处:网络
I have a folder in my server. How do i 开发者_如何学Gozip the folder and download it using php.See the PHP Zip methods.

I have a folder in my server. How do i 开发者_如何学Gozip the folder and download it using php.


See the PHP Zip methods.

Example from PHP manual pages:

<?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");
echo "numfiles: " . $zip->numFiles . "\n";
echo "status:" . $zip->status . "\n";
$    zip->close();
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消