Re: file archive query
| From: | Greg Beaver | Date: | Fri, 24 Jul 2009 17:08:07 +0000 |
| Subject: | Re: file archive query | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-29959@lists.php.net to get a copy of this message | ||
Christian Weiske wrote:
> Hello Vali,
>
>
>> can you tell me if it is possible to add files to a sub-directory
>> within a zip file using the PEAR file_archive module?
>>
>> ie
>> take files xxx.txt, yyy.txt, zzz.txt
>> create zip file called example.zip
>> add files xxx.txt, yyy.txt, zzz.txt to the folder example.zip/temp/
>
> You can either add all files by hand, or use PHP5's native ZipArchive
> functionlity - you should do this if you're running php5. File_Archive
> has been written for php4 since there was no native zip functionality
> yet.
You can also use PHP 5.3's phar extension
<?php
$z = new PharData('example.zip');
$z['temp/xxx.txt'] = file_get_contents('xxx.txt');
$z['temp/yyy.txt'] = file_get_contents('yyy.txt');
$z['temp/zzz.txt'] = file_get_contents('zzz.txt');
?>
Greg