Mantık çok basit ve hızlıdır. Mantığı anlamayan sorsun anlatırım
Örnek;
İyi forumlar...
Kod:
function folderConvertToZipFile(string $source, string $destination) : ****{
$zip = new ZipArchive();
$zip->open('path' . DIRECTORY_SEPARATOR . 'to' . DIRECTORY_SEPARATOR . $source, ZipArchive::CREATE | ZipArchive::OVERWRITE);
$zip->setArchiveComment('ZIP dosyası açıklaması.');
if(!file_exists($destination)) [USER=29804]mkd[/USER]ir($destination);
/** [USER=647246]var[/USER] SplFileInfo[] $files */
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($destination . DIRECTORY_SEPARATOR . $folderName),
RecursiveIteratorIterator::LEAVES_ONLY
);
/** [USER=647246]var[/USER] SplFileInfo $file */
foreach($files as $file)
if(!$file->isDir())
$zip->addFile($file->getPathname(), $file->getRealPath());
$zip->close();
}
Örnek;
Kod:
folderConvertToZipFile('fileName.zip', 'destination');
İyi forumlar...