ftp_nb_continue()
定义和用法
ftp_nb_continue() 函数连续获取/发送文件。(无阻塞)
该函数返回下列值之一:
- FTP_FAILED(发送/获取失败)
- FTP_FINISHED(发送/获取成功)
- FTP_MOREDATA(发送/获取正在进行中)
该函数异步地发送/获取文件。这意味着您的程序可以在文件下载时执行其他操作。
语法
ftp_nb_continue(ftp_connection)
参数 | 描述 |
---|---|
ftp_connection | 必需。规定要使用的 FTP 连接。 |
实例
<?php
$source = "source.txt";
$target = fopen("target.txt", "w");
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");
$status = ftp_nb_fget($conn,$source,$target,FTP_ASCII);
while ($status == FTP_MOREDATA)
{
$status = ftp_nb_continue($conn);
}
if ($status != FTP_FINISHED)
{
echo "Download error";
}
ftp_close($conn);
?>
$source = "source.txt";
$target = fopen("target.txt", "w");
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");
$status = ftp_nb_fget($conn,$source,$target,FTP_ASCII);
while ($status == FTP_MOREDATA)
{
$status = ftp_nb_continue($conn);
}
if ($status != FTP_FINISHED)
{
echo "Download error";
}
ftp_close($conn);
?>