次のコードを使用して、ディレクトリからzipファイルを作成し、httpダウンロードを介してユーザーに提供しようとしています:
// write the file
file_put_contents($path . "/index.html", $output);
// zip up the contents
chdir($path);
exec("zip -r {$course->name} ./");
$filename = "{$course->name}.zip";
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' .urlencode($filename));
header('Content-Transfer-Encoding: binary');
readfile($filename);
zip ファイルを作成することはできますが、http 経由でダウンロードすることはできません。ftp クライアントを使用して作成された zip ファイルをダウンロードすると、Mac の Stuffit Expander はファイルを正常に解凍しますが、http 経由でダウンロードすると、Mac の解凍ツールが無限ループを作成します。これが意味することは、ダウンロードしたファイルが course.zip と呼ばれ、ファイルを解凍すると course.zip.cpgz が得られ、そのファイルを解凍すると course.zip が再び得られるということです。
誰にもアイデアはありますか?
ありがとう!