title: PHP ZipArchive what do status values mean?
body: <p>I am right at the start of trying to write some PHP code to run on a Linux box on an EC2 server that will read files from my S3 bucket, zip them then write the zip file back to the bucket.</p>
  
  <p>I have instantly run in to problems with even creating a simple zip archive from some images on the local disk of the EC2 instance, I am using a script to test out the idea from the PHP manual online and also have tried out a script from David Walsh - <a href="http://davidwalsh.name/create-zip-php" rel="noreferrer">http://davidwalsh.name/create-zip-php</a> which looks like it will be great. Neither result in an actual zip file and both give me different status results - </p>
  
  <p>the first snippet from the php manual (to which i add the variable $thisdir)- </p>
  
  <pre><code>&lt;?php
  $zip = new ZipArchive();
  $filename = "test112.zip";
  $thisdir = "/uploads/";
  if ($zip-&gt;open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
      exit("cannot open &lt;$filename&gt;\n");
  }    
  $zip-&gt;addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt.\n");
  $zip-&gt;addFromString("testfilephp2.txt" . time(), "#2 This is a test string added as testfilephp2.txt.\n");
  $zip-&gt;addFile($thisdir . "/too.php","/testfromfile.php");
  echo "numfiles: " . $zip-&gt;numFiles . "\n";
  echo "status:" . $zip-&gt;status . "\n";
  $zip-&gt;close();
  ?&gt;
  </code></pre>
  
  <p>output = </p>
  
  <blockquote>
    <p>numfiles: 2 status:11</p>
  </blockquote>
  
  <p>I dont see any zip file in my 'uploads' folder</p>
  
  <p>The second bit of code i try ( i wont post the code here) - I pass real files and it returns </p>
  
  <blockquote>
    <p>The zip archive contains 2 files with a status of 0</p>
  </blockquote>
  
  <p>What are the status messages. I have checked to see if I have the correct libraries installed by looking at the output of phpinfo(); and under the ZIP heading I see -</p>
  
  <blockquote>
    <p>Zip   enabled<br>Extension Version    $Id: php_zip.c,v 1.1.2.43 2008/01/18 00:51:38 pajoye Exp $<br>
    Zip version     1.8.11<br>
    Libzip version  0.8.0-compatible </p>
  </blockquote>
  
  <p>I have checked the permissions of the files PHP files with the code I am executing and they are set to 777 as is the folder I am trying to add the ziparchive to. I know that this should not remain at 777. </p>
  
  <p>any ideas why I cannot see a zip file? what do the status values mean? Is there a good tutorial out there for using PHP to zip files on an Amazon S3 bucket? or a good utility to provide this functionality?</p>
  
  <p>cheers</p>