강제 다운로드의 경우 먼저 파일 헤더를 보내야합니다. 당신은 싶어 하나 PHP의 우편 라이브러리를 사용합니다 압축에 대한
header('content-type: application/zip');
header('content-disposition: inline; filename=YOUR_ZIP_FILE_NAME_HERE.ZIP"');
는/출력을 압축 된 내용을 에코. 이 같은
http://ca3.php.net/manual/en/zip.examples.php
뭔가 :
$zip = new ZipArchive();
//the string "file1" is the name we're assigning the file in the archive
$zip->addFile(file_get_contents($filepath1), 'file1'); //file 1 that you want compressed
$zip->addFile(file_get_contents($filepath2), 'file2'); //file 2 that you want compressed
$zip->addFile(file_get_contents($filepath3), 'file3'); //file 3 that you want compressed
echo $zip->file(); //this sends the compressed archive to the output buffer instead of writing it to a file.
출처
2009-06-05 02:21:59
Ian
실제로 실제로 작성하고 zip 파일을 저장하지 않고 "즉석에서"압축 파일을 생성하는 방법이 있나요? 또는 위의 사항을 수행합니까? –
이 예제는 파일을 저장하지 않고 단지 그것을 에코하기 전에 메모리에 유지합니다. "file1", "file2"및 "file3"은 압축하도록 요청한 파일입니다. – Ian