PHP Classes

Zipped file

Recommend this page to a friend!

      Zip File  >  All threads  >  Zipped file  >  (Un) Subscribe thread alerts  
Subject:Zipped file
Summary:Add a txt file
Messages:2
Author:nadeem ahmed
Date:2007-05-02 07:49:09
Update:2007-05-04 00:47:41
 

  1. Zipped file   Reply   Report abuse  
Picture of nadeem ahmed nadeem ahmed - 2007-05-02 07:49:09
Add a new file txt file into a zipped folder how can i do this task through these classes plz guide me thanks

  2. Re: Zipped file   Reply   Report abuse  
Picture of Joshua Townsend Joshua Townsend - 2007-05-04 00:47:41 - In reply to message 1 from nadeem ahmed
In your file was named "example.txt", here is how you would create a new ZIP file with "example.txt" in it:

<?php
require "zip.class.php";

$zipfile = new zipfile;

$zipfile->create_dir(".");
$zipfile->create_file(file_get_contents("example.txt"), "example.txt");

// Then, for example, you could save the file as example.zip

$fh = fopen("example.zip", "wb"); // Remember to use the "b" flag when saving non-ASCII files
fwrite($fh, $zipfile-zipped_file()); // Write the contents
fclose($fh); // Close the file
?>

If you need additional help, just ask.