Quick links: Content - sections - sub sections
EN

Trace: responsezip responsexul responserdf simple responserdf responsezip responserss crud-generic responsexul responsezip

Wiki: Sitemap - Recent changes - Back link

jResponseZip can generate zip file and send it for download to the client. its alias is “zip”:

$rep = $this->getResponse('zip');

You can now indicate $zipFilename property. it will be the zip name proposed to the user for download. Note that it may not be an existing file on the server hard disk.

$rep->zipFilename='myCrazyPackage.zip';

Then, you have to create the zip. $content property is a jZipCreator creator. all its methods can be used to add content to the zip result. (see reference documentation on jZipCreator).

// add  data/truc.txt (stored on the server) content to zip, 
// and alias it with machin.txt name. 
$rep->content->addFile(JELIX_VAR_PATH.'data/truc.txt', 'machin.txt');
 
// add whole "examples" directory content to zip
$rep->content->addDir(JELIX_VAR_PATH.'examples/', 'examples', true);
 
// create a file into zip, given a name and some content
$rep->addContentFile('dynamic.txt', 'generated content as we like');

And you're done :-)

The user will see a dialog asking him to save or open myCrazyPackage.zip, containing a machin.txt file, an examples directory, and a dynamic.txt file.

en/manual-1.0/responsezip.txt · Last modified: 2008/11/19 16:02 (external edit)
Recent changes RSS feed Creative Commons License