Kısacası bu süreyi azaltmak için 1.255 dosyayı zipleyerek tek dosya haline getiriyoruz Tam emin değilim ama httpd download hızı ftp'den daha hızlı sanırım.
Kendim yazmadığım ve bu adreste bulduğum hazır fonksiyonu paylaşmak istedim.
Fonksiyon ve Kullanımını bu adreste bulabilirsiniz.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function Zip($source, $destination) | |
{ | |
if (extension_loaded('zip') === true) | |
{ | |
if (file_exists($source) === true) | |
{ | |
$zip = new ZipArchive(); | |
if ($zip->open($destination, ZIPARCHIVE::CREATE) === true) | |
{ | |
$source = realpath($source); | |
if (is_dir($source) === true) | |
{ | |
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST); | |
foreach ($files as $file) | |
{ | |
$file = realpath($file); | |
if (is_dir($file) === true) | |
{ | |
$zip->addEmptyDir(str_replace($source . '/', '', $file . '/')); | |
} | |
else if (is_file($file) === true) | |
{ | |
$zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file)); | |
} | |
} | |
} | |
else if (is_file($source) === true) | |
{ | |
$zip->addFromString(basename($source), file_get_contents($source)); | |
} | |
} | |
return $zip->close(); | |
} | |
} | |
return false; | |
} | |
// Kullanımı Zip({{Dizin Adı}}, {{Oluşturulacak Arşiv Dosyası}}); | |
Zip('/www/htdocs/hesap/demo/', './arsiv.zip'); |
Not:Oluşturulacak arşiv dosyasının dizini yazılabilinir olmalıdır.
Ek Olarak aynı mantıkla sunucuya yükleyeceğiniz dosyaları tek dosya olarak zipleyip, php ile dosyayı açabilirsiniz.
Web sektöründe zaman ve hız önemlidir.