Birden çok küçük dosyaları geldiğinde Şu FTP bizim sunucu üzerinde delicesine yavaş.
Ben bir zip dosyası oluşturur benim tarayıcıda çalışabilen bir dosya oluşturmak isteyen duyuyorum.
Temelde bu dosya / htdocs oturup olacak
Oluşturduğu zip dosyası tüm / htdocss dosyaları (ve alt klasörler vb) almak ve yapısını taklit gerekir.
Herkes bana doğru yönde işaret edebilir?
Ben aşağıdaki kodu kullanabilirsiniz çalışılıyor.
The only issue is that, I am getting some blank folders
dosya olduğunu söylüyorlar:
C:/xampp/htdocs/booking/zip.php
I get
/C
/C/xampp
/C/xampp/htdocs
/C/xampp/htdocs/booking
/C/xampp/htdocs/booking/image.png
/C/xampp/htdocs/booking/index.php
Ben istemiyorum /C/xampp/htdocs/booking
I just want the zip file to contain image.png index.php
Bunu nasıl düzeltebilirim?
<?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;
}
Zip(dirname(__FILE__), 'testzip.zip');
?>