Zip folder from FTP
<pre><code>&lt;?

$ftp_server = "name.info";
$ftp_user = "user";
$ftp_pass = "pass";

// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); 

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) 
{
    ftp_chdir($conn_id, 'public_html/');
    $contents = ftp_nlist($conn_id, '-la .');
    print_r($contents);
    foreach($contents as $line){
      $file = preg_split('@\s+@', trim($line));
      $name = $file[8];
      $size = $file[4];
      $mode = $file[0];
      if(substr($mode, 0, 1) == '-'){
        //file
        $fd = fopen('d/'.$name, 'w');
        ftp_fget ($conn_id, $fd, $name, FTP_BINARY);
        fclose($fd);
      }else{
        //dir
      }
    }
}
else
    die ("Couldn't connect as $ftp_user\n");

?&gt;
</code></pre>

<p>I want to get all public_html folder. It would be perfect if I could zip it. I tried to write something, but it just doesn't copy those files. What am I missing?</p>
