Welcome Guest, Not a member yet? Register   Sign In
Creating zip files with PHP
#1

[eluser]Sudz[/eluser]
Hi ,
I am uploading files.
Now i want to zip it and then save it on my harddisk.
How do I create Zip files with php.?

help!!!!
#2

[eluser]skiter[/eluser]
http://php.net/manual/en/book.zip.php
#3

[eluser]Sudz[/eluser]
Can you post any sample code?
#4

[eluser]skiter[/eluser]
Sure Wink

Code:
<?php

$zip = new ZipArchive();
$filename = "./test112.zip";

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

$zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt.\n");
$zip->addFromString("testfilephp2.txt" . time(), "#2 This is a test string added as testfilephp2.txt.\n");
$zip->addFile($thisdir . "/too.php","/testfromfile.php");
echo "numfiles: " . $zip->numFiles . "\n";
echo "status:" . $zip->status . "\n";
$zip->close();
?&gt;
#5

[eluser]Sudz[/eluser]
Thanks Brother,
I was trying since 3 hours.
#6

[eluser]InsiteFX[/eluser]
What's wrong with using the CodeIgniter Zip Class?
#7

[eluser]Sudz[/eluser]
I used Zip class its good,Actually i wanted to zip file in one of my old non CI project.
Thanks for giving your valuable time.




Theme © iAndrew 2016 - Forum software by © MyBB