কম্পিউটার টিউটোরিয়াল

PHP-তে ডিরেক্টরি জিপ (Zip) করার পদ্ধতি

PHP-তে ফোল্ডার জিপ ও আনজিপ করার জন্য ZipArchive ক্লাস ব্যবহার করা যায়। PHP 5.3 পর্যন্ত এই ক্লাস বিল্ট-ইন। উইন্ডোজ ব্যবহারকারীদের php.ini-তে php_zip.dll ইনেবল করতে হয়।

উদাহরণ

<?php 
// ডিরেক্টরির নাম 
$pathdir = "Directory Name/"; 
// জিপ ফাইলের নাম 
$zipcreated = "test.zip"; 
// নতুন জিপ ক্লাস তৈরি 
$newzip = new ZipArchive; 
if($newzip->open($zipcreated, ZipArchive::CREATE) === TRUE) { 
    $dir = opendir($pathdir); 
    while($file = readdir($dir)) { 
        if(is_file($pathdir.$file)) { 
            $newzip->addFile($pathdir.$file, $file); 
        } 
    } 
    $newzip->close(); 
} 
?>
  1. PHP-এ zip_entry_close() ফাংশন

  2. PHP-তে rmdir() ফাংশন

  3. PHP-তে is_dir() ফাংশন

  4. PHP-তে dirname() ফাংশন