PHP ftp_nb_fget() 函数
PHP 教程
· 2019-01-26 09:57:26
定义和用法
ftp_nb_fget() 函数从 FTP 服务器上下载一个文件并保存到本地一个已经打开的文件中。(无阻塞)
该函数返回下列值之一:
- FTP_FAILED(发送/获取失败)
- FTP_FINISHED(发送/获取成功)
- FTP_MOREDATA(发送/获取正在进行中)
与 ftp_fget() 不同,该函数异步地获取文件。这意味着您的程序可以在文件下载时执行其他操作。
语法
ftp_nb_fget(ftp_connection,local,remote,mode,resume)
| 参数 | 描述 |
|---|---|
| ftp_connection | 必需。规定要使用的 FTP 连接。 |
| local | 必需。规定要保存内容的本地一个已经打开的文件。 |
| remote | 必需。规定从中复制内容的文件的路径。 |
| mode | 必需。规定传输模式。可能的值:
|
| 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);
?>
点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html
The Creative Curve
Allen Gannett / Knopf Doubleday Publishing Group / 2018-6-12
Big data entrepreneur Allen Gannett overturns the mythology around creative genius, and reveals the science and secrets behind achieving breakout commercial success in any field. We have been s......一起来看看 《The Creative Curve》 这本书的介绍吧!