ftp_put
(PHP 4, PHP 5)
ftp_put — 上传文件到 FTP 服务器
<h3>说明</h3>
 bool <strong>ftp_put</strong>
  ( resource <code>$ftp_stream</code>
 , string <code>$remote_file</code>
 , string <code>$local_file</code>
 , int <code>$mode</code>
 [, int <code>$startpos</code>
] )
<p>
 <strong>ftp_put()</strong> 函数用来上传由 <code>local_file</code>
 参数指定的文件到 FTP 服务器,上传后的位置由
 <code>remote_file</code> 指定。传输模式参数
</p>参数
ftp_stream
       
FTP 连接资源。
remote_file
       远程文件路径。
local_file
       本地文件路径。
mode
       
        传送模式,只能为 FTP_ASCII(文本模式)或 FTP_BINARY(二进制模式)。
       
startpos
       
返回值
    成功时返回 TRUE, 或者在失败时返回 FALSE。
   
范例
Example #1 ftp_put() 实例
<?php
$file = 'somefile.txt';
$remote_file = 'readme.txt';
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "successfully uploaded $filen";
} else {
echo "There was a problem while uploading $filen";
}
// close the connection
ftp_close($conn_id);
?>
更新日志
       版本
       说明
       4.3.0
        增加 startpos 参数。
  
参见
ftp_pasv() - 返回当前 FTP 被动模式是否打开 ftp_fput() - 上传一个已经打开的文件到 FTP 服务器 ftp_nb_fput() - 将文件存储到 FTP 服务器 (非阻塞) ftp_nb_put() - 存储一个文件至 FTP 服务器(non-blocking)