PHP FTP Upload Thousands of Files

I wrote a small FTP class that I used to move files from a local server to a remote server. This is done by checking an array of local files with an array of files on a remote server. If the file exists on the remote server, it will not download it.

The script works fine for small file sizes, but I noticed that up to 3000 image images can be transferred on the local server, which seems to cause the script to flop 100 or so.

How can I modify the script to process thousands of image transfer files?

+3
source share
4 answers

cron script 80 .

+3

, , script ( php), , script -. php, , ( ). , script ( cli php).

, , . rsync ( linux), .

0

- php , ( ) cron .

<?
echo "Running cli syncfiles.php";
system("&php syncfiles.php"); // & pushes file to background processing on linux 
?>

, ftp / , , , - .

<?
$counter=0;
for($i=0;$i<$numftpfiles;$i++)
{
   syncfile($i); // this represents your sync code
   usleep(250000); // sleep for 1/4 second
   $count++;
   if($count>50)
   {
     usleep(30000000); // sleep for 30 seconds
     $count=0;
   }
}
?>
0

Then you can archive first in php http://www.php.net/manual/en/book.zip.php

Then upload one large zip file. The overall file size is unlikely to change, but I found that when transferring a large number of files through my WAN, it is still faster.

-Will be

0
source

Source: https://habr.com/ru/post/1740118/


All Articles