ftp_nb_get() 函数在 PHP 中
ftp_nb_get() 函数从 FTP 服务器下载一个文件。
语法
ftp_nb_get(con,local_file,server_file,transfer_mode,beg_pos);
参数
con − FTP 连接
local_file − 本地文件路径
server_file − 要下载的服务器文件
transfer_mode − 这是传输模式。以下是可能的值 −
- FTP_ASCII,或
- FTP_BINARY
beg_pos − 下载开始的位置
返回
ftp_nb_get() 函数返回以下任一值 −
FTP_FAILED − 发送或接收失败
FTP_FINISHED − 发送或接收已完成
FTP_MOREDATA − 发送或接收正在进行中
示例
以下是示例
<?php
$ftp_server = "192.168.0.4";
$ftp_user = "jacob";
$ftp_pass = "tywg61gh";
$con = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($con, $ftp_user, $ftp_pass);
$my_serverfile = "demo.txt";
$local_file = "new.txt";
$c = ftp_nb_get($con, $local_file , $my_serverfile, FTP_ASCII)
while ($c == FTP_MOREDATA){
// continue downloading
$c = ftp_nb_continue($con);
}
if ($c != FTP_FINISHED) {
echo "Error downloading the server file!";
exit(1);
}
// close
fclose($file_pointer)
?>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言
C++
C#
MongoDB
MySQL
Javascript
PHP