views:

44

answers:

1

Hi

Using the Create ZIP File PHP class I have the following line of code

$createZip->get_files_from_folder('blog/wp-content/themes/', 'themes/');

Am I right in thinking that this code gets the files and sub directories from 'blog/wp-content/themes/' creates a new folder entitled 'themes', and then puts these files and sub directories into this themes folder.

Thanks

Rifki

A: 

I don't know which class/library you are using but here is the one that allows you to zip all files present in specified directory:

Create Zip File class

Usage:

$fileToZip="License.txt";
$fileToZip1="CreateZipFileMac.inc.php";
$fileToZip2="CreateZipFile.inc.php";

$directoryToZip="./"; // This will zip all the file(s) in this present working directory

$outputDir="/"; //Replace "/" with the name of the desired output directory.
$zipName="test.zip";

include_once("CreateZipFile.inc.php");
$createZipFile=new CreateZipFile;


//Code toZip a directory and all its files/subdirectories
$createZipFile->zipDirectory($directoryToZip,$outputDir);

$rand=md5(microtime().rand(0,999999));
$zipName=$rand."_".$zipName;
$fd=fopen($zipName, "wb");
$out=fwrite($fd,$createZipFile->getZippedfile());
fclose($fd);
$createZipFile->forceDownload($zipName);
@unlink($zipName); 

Just specify the correct path to variable $directoryToZip and all files in it will be zipped.

Sarfraz
This is great Thank you for your help
Rifki