ZIP은 요청시 사용자 개인 디렉터리 인 스크립트를 실행하고 있습니다.PHP .ZIP 객체 - str_replace 폴더 경로?
디렉토리에 대한 경로는 다음과 같습니다
../temp/useremail/ 우편이 실제로 다운로드
,이 폴더 경로가 분명 끔찍한 보이는 (그 안에 표시되는 방법도). 내가 않는 str_replace를 사용하여 시도하지만 효과가 있었다
에서 useremail/
: 나는 간단하게 표시 할. 여기에 내 코드가있다 :
$zip = new ZipArchive();
$exists = file_exists('../temp/' . $email . '/theme-' . $email . '.zip');
$delete = '../temp/' . $email . '/theme-' . $email . '.zip';
if($exists) {
unlink($delete);
}
if ($zip->open('../temp/' . $email . '/theme-' . $email . '.zip', ZIPARCHIVE::CREATE) !== TRUE) {
die("Could not open archive");
}
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("../temp/$email/"));
foreach ($iterator as $key => $value) {
$_key = str_replace("../temp/'.$email.'/", "", $key);
$zip->addFile(realpath($_key), $_key) or die("ERROR: Could not add file: $key");
}
$zip->close();
'ZipArchive :: renameName' 시도 - http://www.php.net/manual/en/ziparchive.renamename.php – scibuff
빠른 모양이 있었지만 사용하지 않는 한 도움이되지 않는 것 같습니다. 잘못이야. 현재 스크립트에 어떻게 통합 시키시겠습니까? – tctc91