On 4/4/06, gobblez <[EMAIL PROTECTED]> wrote:
>
> Can I suggest an introduction being added, with example uses? How it
> works? And what to name the file that you place your zipComponent
> class in (and where).
hmm, aren't they already there?
<?php
class WebpagesController extends AppController
{
var $name = 'Webpages';
var $components = array('zip');
function zip()
{
// adds directories inside zip for easy organization when
unzipped, add as many as needed
$this->zip->addDirectory("mycontent/");
// adds files to directories, feed in the string (ascii or binary)
and then the dir+name of file
$this->zip->addFile("THIS IS A TEST", "mycontent/exampletext.txt");
$this->zip->addFile("THIS IS TEST 2", "mycontent/exampletext2.txt");
// specify where you will temporarily store zip
// make sure dir is chmod 777 for access
$fileName = "files/test.zip";
// write zip
$fd = fopen ($fileName, "wb");
$out = fwrite ($fd, $this->zip->getZippedfile());
fclose ($fd);
// send headers to browser to download the file
$this->zip->forceDownload($fileName);
// delete the zip file from server
@unlink($fileName);
}
}
?>
personally I think I'd prefer the write zip section to be contained
within the component so you could do:
$this->zip-saveZip ("files/test.zip");
function saveZip ($filename)
{
$fd = fopen ($fileName, "wb");
$out = fwrite ($fd, $this->getZippedfile());
fclose ($fd);
}
haven't tested the above mind!
jb
--
jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---