您现在的位置是:首页 > PHP函数

李清波 2021-06-17 PHP函数 1495 复制当前网址

ftp_nb_fget



PHP ftp_nb_fget() 函数

定义和用法

ftp_nb_fget() 函数从 FTP 服务器上下载一个文件并保存到本地已经打开的一个文件中 (non-blocking)。

该函数返回下列值:

  • FTP_FAILED (send/receive failed)

  • FTP_FINISHED (send/receive completed)

  • FTP_MOREDATA (send/receive in progress)

与 ftp_fget() 不同,该函数异步地获取文件。这意味着您的程序可以在文件下载时执行其他操作。


语法

ftp_nb_fget(ftp_connection,local,remote,mode,resume)

参数描述
ftp_connection必需。规定要使用的 FTP 连接(FTP 连接的标识符)。
local必需。规定本地文件。
remote必需。规定从中进行拷贝的文件的路径。
mode

必需。规定传输模式。可能的值有:

  • FTP_ASCII

  • FTP_BINARY

resume必需。规定在远程文件中的何处开始拷贝。默认是 0。


例子

本例把文本从 "source.txt" 拷贝到 "target.txt" 中:

<?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");ftp_nb_fget($conn,$target,$source,FTP_ASCII);ftp_close($conn);
?>


文章来源:https://www.liqingbo.com/blog-669.html

上一篇:ftp_nb_fput

下一篇:ftp_nb_continue

评论