代碼: 選擇全部
class createDirZip extends createZip {
function get_files_from_folder($directory, $put_into) {
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if (is_file($directory.$file)) {
$fileContents = file_get_contents($directory.$file);
$this->addFile($fileContents, $put_into.$file);
} elseif ($file != '.' and $file != '..' and is_dir($directory.$file)) {
$this->addDirectory($put_into.$file.'/');
$this->get_files_from_folder($directory.$file.'/', $put_into.$file.'/');
}
}
}
closedir($handle);
}
}
代碼: 選擇全部
$createZip = new createDirZip;
$createZip->addDirectory('themes/');
$createZip->get_files_from_folder('blog/wp-content/themes/', 'themes/');
代碼: 選擇全部
$fileName = 'tmp/archive.zip';
$fd = fopen ($fileName, 'wb');
$out = fwrite ($fd, $createZip->getZippedfile());
fclose ($fd);
$createZip->forceDownload($fileName);
@unlink($fileName);
http://www.web-development-blog.com/arc ... n-the-fly/
http://olederer.users.phpclasses.org/pa ... nload.html