<?php 
error_reporting(0);
function create_zip($files = array(),$destination = '') {
    $zip = new ZipArchive();
    $zip->open($destination, ZipArchive::CREATE);
    foreach($files as $file){
      $download_file = file_get_contents($file);
      $zip->addFromString(basename($file),$download_file);
    }
    $zip->close();
   // header('Content-type: application/zip');
   // header('Content-Disposition: attachment; filename='.basename($destination)); 
}


$files = array();
$dirPath = "./images";
$files_to_zip = glob($dirPath . "/*");
$t=date('Y-m-d');
$fname = 'bkimages'.$t;
create_zip($files_to_zip,$fname.'.zip');

		$start_date = date('Y-m-d H:i:s');
		$end_date = date('Y-m-d H:i:s');
		$ins_query = mysqli_query($connect,"insert into backup_details(start_date,end_date,status,file_name,created_by) values('".$start_date."','".$end_date."','0','".$fname.'.zip'."','1')") or die(mysqli_error($connect));


