Zip On The Fly (PHP Zip File Secara Online)
[ Hits : 1514 ] [ Print ] [ Demo ]Ada banyak alasan kita men-Zip file, salah satunya untuk menyatukan beberapa file dalam sebuah paket file, secara konvensional untuk men-Zip file biasanya kita menggunakan beberapa aplikasi seperti winzip, winrar, 7Zip, dll
Namun bagi anda yang ingin men-Zip file secara online (on the fly) kita bisa menggunakan modul php. Hasil file zip yang akan didownload akan kelihatan seolah-olah file zip tersebut disimpan dalam web server, padahal aslinya hanya sekumpulan script php yang di generate.
Apabila script anda berfungsi, anda akan melihat tampilan :
Berikut script lengkapnya :
1- <?php
2- require_once('CreateZip.inc.php');
3- //load class zip
4- $createZip = new createZip;
5-
6- //add direktory csp
7- $createZip -> addDirectory("folder-baru/");
8-
9- //masukan file ke array (bisa lebih dari satu file)
10- $aryfile=array('CreateZip.inc.php','testzip.php');
11-
12- for($i=0;$i<count($aryfile);$i++){
13- $fileContents = file_get_contents($aryfile[$i]);
14- $createZip -> addFile($fileContents, "folder-baru/".$aryfile[$i]);
15- }
16-
17- //set nama output file
18- $fileName = "csp-test.zip";
19- $fd = fopen ($fileName, "wb");
20- $out = fwrite ($fd, $createZip -> getZippedfile());
21- fclose ($fd);
22- echo "<h1>PDF on the Fly, <a href='csp-test.zip'>download disini</a></h1>";
23- ?>
24-
2- require_once('CreateZip.inc.php');
3- //load class zip
4- $createZip = new createZip;
5-
6- //add direktory csp
7- $createZip -> addDirectory("folder-baru/");
8-
9- //masukan file ke array (bisa lebih dari satu file)
10- $aryfile=array('CreateZip.inc.php','testzip.php');
11-
12- for($i=0;$i<count($aryfile);$i++){
13- $fileContents = file_get_contents($aryfile[$i]);
14- $createZip -> addFile($fileContents, "folder-baru/".$aryfile[$i]);
15- }
16-
17- //set nama output file
18- $fileName = "csp-test.zip";
19- $fd = fopen ($fileName, "wb");
20- $out = fwrite ($fd, $createZip -> getZippedfile());
21- fclose ($fd);
22- echo "<h1>PDF on the Fly, <a href='csp-test.zip'>download disini</a></h1>";
23- ?>
24-
- Adwords (3)
- Cpanel (3)
- Domain Manager (7)
- Facebook (3)
- Flash (1)
- FTP (1)
- Google Tools (7)
- Order (3)
- PHP Excel (7)
- PHP PDF (4)
- PHP Zip (1)
- Promo (6)
- Twitter (2)
- Video Website (1)
- Web Tools (4)





