PHP Classes

Step-by-step for a noob?

Recommend this page to a friend!

      Create ZIP File  >  All threads  >  Step-by-step for a noob?  >  (Un) Subscribe thread alerts  
Subject:Step-by-step for a noob?
Summary:I'm sorry to be obtuse, but I can't even get this class to burp.
Author:kevin duda
Date:2008-02-10 01:51:17

  1. Step-by-step for a noob?   Reply   Report abuse  
Picture of kevin duda kevin duda - 2008-02-10 01:51:18
Hi there. I love the idea of this class but i'm unable to produce a valid zip. Everything I produce is the correct size, but i suspect is not packed correctly.

here is my code:


$createZip = new createZip;

$createZip -> addDirectory("dir/");

$fileContents = file_get_contents("2007-09-09_tilton_band/2007-09-09_tilton_band-001-proof.jpg");
$createZip -> addFile($fileContents, "dir/2007-09-09_tilton_band-001-proof.jpg");
//file_put_contents("tilton.jpg",$fileContents); //this was added to make sure i was getting the correct image data. I am.

$fileName = "";
$fileResource = fopen ($fileName, "wb");
$out = fwrite ($fileResource, $createZip -> getZippedfile());
fclose ($fileResource);

$createZip -> forceDownload($fileName);


I suspect the problem is with the "dir/" sections. I assumed that this was a method to add a directory structure to the zip file, bt nothing I put in that space works.

By any chance could you post the content of the demo file that's linked in the page? A real-world example would be more enlightening to me, personally.

thanks so much!