Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to zip a folder using php

<?php
  
// Enter the name of directory
$pathdir = "Directory Name/"; 
  
// Enter the name to creating zipped directory
$zipcreated = "Name of Zip.zip";
  
// Create new zip class
$zip = new ZipArchive;
   
if($zip -> open($zipcreated, ZipArchive::CREATE ) === TRUE) {
      
    // Store the path into the variable
    $dir = opendir($pathdir);
       
    while($file = readdir($dir)) {
        if(is_file($pathdir.$file)) {
            $zip -> addFile($pathdir.$file, $file);
        }
    }
    $zip ->close();
}
  
?>
Comment

PREVIOUS NEXT
Code Example
Php :: php stop execution 
Php :: get taxonomy term meta by id 
Php :: continue not in the loop or switch 
Php :: exec command not working in php but works in terminal 
Php :: wp php get_the_category posts loop 
Php :: php last day of month 
Php :: laravel update by id 
Php :: db raw update laravel 
Php :: how to limit word in php 
Php :: laravel ckeditor 
Php :: php artisan update table 
Php :: laravel create text file 
Php :: delete all records from table using button laravel Eloquent 
Php :: image store short method in laravel 
Php :: php previous page 
Php :: ubuntu laravel storage permission 
Php :: laravel model exists id 
Php :: format date in php 
Php :: twig variable exists 
Php :: The `url` supplied for the path (./nova) repository does not exist 
Php :: foreign key laravel migration 
Php :: php oop 
Php :: get all laravel validation failed messages 
Php :: get featured image id wordpress 
Php :: hello world php 
Php :: unable to open file error in php 
Php :: laravel slug 
Php :: laravel findorfail 
Php :: php global variable function 
Php :: random string in php 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =