Zip File dengan PHP

php

Di bawah ini merupakan script PHP untuk melakukan zip file.

<?php

$zip = new ZipArchive();
$filename = “target_file.zip”;

if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
exit(“cannot open <$filename>\n”);
}

$zip->addFile(“target_file_1.txt”);
$zip->addFile(“target_file_2.txt”);
$zip->addFile(“target_file_3.txt”);

echo “numfiles: ” . $zip->numFiles . “\n”;
echo “status:” . $zip->status . “\n”;
$zip->close();

?>

Script di atas bertujuan untuk melakukan kompresi zip dari 3 file txt yaitu target_file_1.txt. target_file_2.txt dan target_file_3.txt menjadi file zip bernama target_file.zip.

a simple man

Tagged with:
Posted in Knowledge, Tips

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

July 2010
M T W T F S S
« Mar   Aug »
 1234
567891011
12131415161718
19202122232425
262728293031  
Blog Stats
  • 72,745 hits
%d bloggers like this: