ftp_nb_put()函数将文件上传到FTP服务器。
ftp_nb_put(con,remote_file,local_file,transfer_mode,beg_pos);
con -FTP连接
remote_file-要上传到的文件
local_file-要上传的本地文件路径
transfer_mode-这是传输模式。以下是可能的值:
-FTP_ASCII,或
-FTP_BINARY
beg_pos-开始下载的位置
ftp_nb_put()函数返回以下任何值-
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); $local_file = "new.txt"; $my_serverfile = "serverfile.txt"; $c = ftp_nb_put($con, $my_serverfile, $local_file, FT_BINARY) while ($c == FTP_MOREDATA) { //继续下载 $c = ftp_nb_continue($con); } if ($c != FTP_FINISHED){ echo "下载服务器文件时出错!"; exit(1); } //关闭 ftp_close($con); ?>