Before Starting...
Know about file location
My File exist in C:\xampp\htdocs\ftp\index.phpIn ftp directory we have 6 more directories and names are
- John
- Jill
- Cafe
- Monit
- Rifle
- Kim.
index.php
<?php
$ar = array();
$directory = "./";
$files = glob($directory . "*", GLOB_ONLYDIR );
foreach($files as $file)
{
$ar[] = basename($file);
}
$a =count($ar);
for($i=0;$i<$a;$i++)
{
$filename= $ar[$i];
$source_path= $filename;
$the_folder =$source_path;
$zip_file_name = $the_folder.".zip";
$za = new FlxZipArchive;
$res = $za->open($zip_file_name, ZipArchive::CREATE);
if($res === TRUE)
{
$za->addDir($the_folder, basename($the_folder));
$za->close();
}
else { echo 'Could not create a zip archive';}
} ?>
No comments:
Post a Comment