PHPでファイルのZIP圧縮をする際に便利に使えるクラスライブラリ
2007年10月02日-
スポンサード リンク
Tutorial: Create a zip file from folders on the fly - Web Development Blog
For a future project I needed these days some easy to use zip or gzip class to create a zip file from files / folders inside a specified directory.
PHPでファイルのZIP圧縮をする際に便利に使えるクラスライブラリ。
次のように、圧縮対象のディレクトリや、複数ファイルをアーカイブに登録するためのメソッドが用意されています。
$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);
PHPでサーバ側のファイルをバックアップする場合に便利に使うことが出来そうです。
スポンサード リンク
Advertisements
SITE PROFILE
最新のブログ記事(新着順)
- 2012年5月24日 管理人のブックマーク
- 立体感がリアルなON・OFFスイッチ実装jQueryデモ
- PHPフレームワークにTwitter,Facebook等の認証を速攻実装できる「Opauth」
- 2012年5月23日 管理人のブックマーク
- PC・スマホ・タブレットで動くクールなHTML5スライドショー実装ができる「Juicebox」
- 既にここまで出来るWebGLのデモ22
- 2012年5月22日 管理人のブックマーク
- CSSな吹き出しを作れるWEBツール「cssarrowplease」
- PHP+Bootstrapで書かれた美しいGitリポジトリビューア「GitList」
- 2012年5月21日 管理人のブックマーク
- 過去のエントリ



















間違いの指摘をしていただける方はメール、あるいはTwitter/FBでお願いします(クリック)



