0
내 서버를 통해 zip 다운로드를 시작하려고합니다.내 .zip 파일이 비어있는 이유는 무엇입니까?
이 zip 파일 형식에는 생성되는 pdf 수가 포함되어 있습니다.
문제는 가방과 덤프가 있지만 손상된 부분을 열어 두거나 오류가 있다는 것과 압축을 풀면 비어 있음을 알리는 것입니다.
여기 전체 절차를 수행합니까? readfile($filename)
이전에 descargar.php
<?php
$zip = new ZipArchive();
$filename = 'walkingdead.zip';
if($zip->open($filename,ZIPARCHIVE::CREATE)===true) {
// Get real path for our folder
$rootPath = realpath('../walkingdead');
$zip->open('walking.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
// Create recursive directory iterator
/** @var SplFileInfo[] $files */
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootPath),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file)
{
// Skip directories (they would be added automatically)
if (!$file->isDir())
{
// Get real and relative path for current file
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($rootPath) + 1);
// Add current file to archive
$zip->addFile($filePath, $relativePath);
}
}
//Sin notificaciones, y que el server no comprima
@ini_set('error_reporting', E_ALL & ~ E_NOTICE);
@ini_set('zlib.output_compression', 'Off');
//Encabezados para archivos .zip
header('Content-Type: application/zip');
header('Content-Transfer-Encoding: Binary');
//El nombre predeterminado que verá el cliente
header('Content-disposition: attachment; filename="' . basename($filename) . '"');
//Que no haya límite en la ejecución del script
@set_time_limit(0);
//Imprime el contenido del archivo
readfile($filename);
// Zip archive will be created only after closing object
$zip->close();
}
기본 디버깅 :'readfile ($ files);'디렉토리 타이토 레이터 객체를 전달할 때 readfile()이 정확히 수행한다고 생각합니까? –
내 .zip 파일을 내 PC 사용자에게 다운로드하려고합니다. – David
그런 다음 파일 이름을 예상하는 함수에 개체를 공급하는 이유는 무엇입니까? –