开发者

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.


  1. have a look at http://php.net/manual/en/book.ftp.php

  2. 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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜