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?
My script looks like this:
$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
");
}
if(!ftp_login($conn,$ftp_user,$ftp_pass))
{
ftp_quit($conn);
exit("Can't login
");
}
ftp_chdir($conn,$DIR);
$files = ftp_nlist($conn,'.');
for($i=0;$i<count($files);$i++)
{
if(!ftp_get($conn,$files[$i],$files[$i],FTP_BINARY))
{
echo "Can't download {$files[$i]}
";
}
else
{
echo "Successfully transferred images!";
}
}
ftp_quit($conn);
Thank you.