QUICK TUTORIAL
This example is found in the PHP .CHM manual released by http://ww.php.net I have tested it personally, it works brilliant.
It reads all the contents from file MyDataFile.txt, compress it and save results into a variable $gzdata, and save that data to file called New.txt.gz, which can easily be opened via WINZIP, WINRAR or any program supports opening GZ files.
This is best for creatign backups.
| CODE | <? $file_to_compress = "MyDataFile.txt"; //any type of file $gz_file_to_produce=""New.txt.gz";
$data = implode("", file($file_to_compress)); $gzdata = gzencode($data, 9); $fp = fopen($gz_file_to_produce, "w"); fwrite($fp, $gzdata); fclose($fp); ?> |
|
|
|