download a file asynchronously using FTP
Which function to you use to download a file asynchronously开发者_StackOverflow using FTP and save it locally?
Really quick idea:
// Assumed Variables and Values
// $ftpUser = 'FTP_Username'; or FALSE if not needed
// $ftpPass = 'FTP_Password'; or FALSE is not needed
// $ftpHost = 'FTP_Hostname';
// $ftpFile = 'FTP_Filename';
// $locFile = 'Local File Location, from Root';
$wgetCommand = 'wget ftp://'.
( $ftpUser ? $ftpUser.':'.$ftpPass : '' ).
'@'.$ftpHost.'/'.$ftpFile.
' -O '.$locFile;
command( $wgetCommand.' &' );
The ampersand at the end of the command means to execute the command in the background and not to wait for a response, this should produce the "async" performance you request.
have a look at http://php.net/manual/en/book.ftp.php
if you still need help, please try to make it clear what exactly it is you want. For example, what you mean by "asynchronously" in the context of PHP - you are aware PHP usually does no threading and each script times out fast?
精彩评论