title: Downloading only new images from FTP server in PHP
body: <p>I made a little script which allows me to download images from FTP server. But, the thing is, whenever I execute the script, ALL images are downloaded. Is there any way to rewrite the code so that it only downloads new images?  </p>
  
  <p>My script looks like this:</p>
  
  <pre><code>$ftp_server = "my_server_ip";
  $ftp_user = "my_user_name";
  $ftp_pass = "my_password";
  $DIR="my_path_to_images_folder";
  
  $conn = ftp_connect($ftp_server);
  if(!$conn)
  {
      exit("Can not connect to server: $ftp_server\n");
  }
  
  if(!ftp_login($conn,$ftp_user,$ftp_pass))
  {
      ftp_quit($conn);
      exit("Can't login\n");
  }
  
  ftp_chdir($conn,$DIR);
  
  $files = ftp_nlist($conn,'.');
  for($i=0;$i&lt;count($files);$i++)
  {
      if(!ftp_get($conn,$files[$i],$files[$i],FTP_BINARY))
      {
          echo "Can't download {$files[$i]}\n";
      }
      else
      {
          echo "Successfully transferred images!";
      }
  }
  
  ftp_quit($conn);
  </code></pre>
  
  <p>Thank you.</p>