나는 HTML, CSS 및 이미지 파일을 생성 중이며 ZipArchive를 사용하여 압축 파일로 압축합니다. 생성 된 자산이 유효하다는 것을 확인했지만 일련의 파일을 압축하려고하면 결과 아카이브 파일을 열 수 없습니다.ZipArchive 발행물 "PHP 파일에서 21 번째 오류"
PHP에서 오류가 발생하지 않으며 echo $zip->close()
이 true로 표시되면 문제없이 파일에 쓰고 저장할 수 있다고 가정합니다.
"Unable to expand "filename.zip" into "Downloads". (Error 21 - Is a directory.)
여기에 무엇이 잘못 될 수 있습니다 맥과 지퍼를 열면 아카이브 유틸리티이 오류가 발생합니다?
이<?php
$ref = $_SERVER["HTTP_REFERER"];
$html = $_REQUEST['html'];
$images = $_REQUEST['images'];
$folder = uniqid();
$prepped = str_replace($ref.'server/php/files/', 'images/', $html);
mkdir("./runways/$folder", 0777);
mkdir("./runways/$folder/images", 0777);
mkdir("./runways/$folder/css", 0777);
file_put_contents('./runways/'.$folder.'/index.html',$prepped);
copy('../../css/runway.css', './runways/'.$folder.'/css/runway.css');
foreach($images as $image) {
$i = urldecode(str_replace($ref.'server/php/files/', '', $image));
$idata = file_get_contents('./files/'.$i);
file_put_contents('./runways/'.$folder.'/images/'.$i, $idata);
}
//echo $ref.'server/php/runways/'.$folder.'/';
$sourcefolder = './runways/'.$folder.'/';
$zipfilename = $folder.'.zip';
$dirlist = new RecursiveDirectoryIterator($sourcefolder);
$filelist = new RecursiveIteratorIterator($dirlist);
ini_set('max_execution_time', 5000);
$zip = new ZipArchive();
if ($zip->open('./zips/'.$zipfilename, ZIPARCHIVE::CREATE) !== TRUE) {
die ("Could not open archive");
}
foreach ($filelist as $key=>$value) {
$zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
}
$zip->close();
echo $ref.'server/php/zips/'.$zipfilename;
?>