si KENCUR, Masih Bau Kencur

kencur,sikencur,aplikasi,tips dan trik, informasi,aplikasi sekolah gratis,pendidikan,aplikasi sekolah,bejalar office

Aplikasi SPPD

Aplikasi SPPD Mini

PHP Create Zip File

php-create-zip-file.png

php-create-zip-file.png

PHP Create Zip File. Something needs to be considered when creating a zip file using php is already loaded or not the zlib library by php runtime. With zlib enables you to transparently read or write ZIP compressed archives and the files inside them.

Requirements
PHP 4
The bundled PHP 4 version requires » ZZIPlib, by Guido Draheim, version 0.10.6 or later
PHP 5.2.0 or later
This extension uses the functions of » zlib by Jean-loup Gailly and Mark Adler.

To use these functions, make sure that zlib have been loaded by php runtime. Use this trick to find zlib has been loaded by php, create new file php (Ex:phpinfo.php), fill the file with this(without quote): “<?php phpinfo();?>“. Put it on the web folder then open with mozilla fire fox.

If zlib have been loaded by php, Let’ start creating the Zip file.
* Create files 1.txt, 2.txt, 3.txt, 4.txt And Create makezip.php (in the same directory with file 1.txt).
Fill the makezip.php with this:

<php 
$zip = new ZipArchive(); $filename = "test.zip"; 
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
	exit("cannot open");
	}
$zip->addFromString("1.txt", "time create zip ".time()." #1 This is a test string added as 1.txt.\n");
$zip->addFromString("2.txt" . time(), "#2 This is a test string added as 2.txt.\n");
$zip->addFile($thisdir . "3.txt","4.txt"); // file 3.txt while be renamed to 4.txt
echo "numfiles: " . $zip->numFiles . "<br />";
echo "status:" . $zip->status . "<br />";
echo "Directory: ".getcwd()."<br />Filename: $filename";
$zip->close();
?>

Upload files to your web directory, then open up makezip.php with your web browser. Look at your web directory, you will see the test.zip. :D

Download PHP Create Zip File

7 thoughts on “PHP Create Zip File”

  1. Angga Rizki Ramadhan berkata:

    :gg:
    .-= Angga Rizki Ramadhan´s last blog ..TOP 10 Foto Objek Antariksa dari ESO =-.

  2. Detox diet plan berkata:

    Thats good, your blog is cool, i like it. Thanks for the efforts my friend.
    My website is Slim fast diet.

  3. Hello, I simply wanted to take time to make a comment and say I have really enjoyed reading your site.
    My website is about best acne treatment

  4. bPapsbrabs berkata:

    iphone 4 unlock
    how to unlock iphone 4
    unlock iphone 4

  5. ChinChin berkata:

    Good job! I would say that I really enjoy reading about your post! it a great effort! Thank you for the share!

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *