Jump to content

Multithreaded / Simultaneous FTP_put


cms server

Recommended Posts

Hi,

I am able to transfer with no problems using:

ftp_put

 

I have multiple files that are found locally in different locations

and then transfer consecutively,

the transfers are registering slowly one after another on the FTP server

(each one has to complete first).

The server is multithreaded and could handle lots of simultaneous transfers.

 

How do I start an FTP transfer to work in background and then move on to

starting the other FTP transfers in this loop?

 

 

if (ftp_put($fp, $remotevar, $src, FTP_BINARY)) {

$success = true;

$sizefile = (filesize($src) < 1024 ? 0 : ((filesize($src) / 1024) / ((time() +1) - $filestart)));

echo "[" . strftime("%d/%m/%Y %H:%M:%S", time()) . "] <= file transfer finished! [@ " . sprintf("%.2f kb/s", $sizefile) . "]\n";

 

} else {

echo "[" . strftime("%d/%m/%Y %H:%M:%S", time()) . "] =! transfer failed from $src to {$ftp_server['remotePath']}{$destname}\n";

$success = false;

}

} else {

echo "[" . strftime("%d/%m/%Y %H:%M:%S", time()) . "] =! No transfer required file is current \n";

$success = false;

}

 

echo "[" . strftime("%d/%m/%Y %H:%M:%S", time()) . "] <= closed connection\n";

ftp_quit($fp);

 

$servar++;

}

echo "[" . strftime("%d/%m/%Y %H:%M:%S", time()) . "] done!\n";

 

return $success;

}

 

 

Link to comment
https://forums.phpfreaks.com/topic/84762-multithreaded-simultaneous-ftp_put/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.