(PHP 4, PHP 5)
ftp_put — 上傳文件到 FTP 服務(wù)器
說明
bool ftp_put ( resource$ftp_stream
, string $remote_file
, string $local_file
, int $mode
[, int $startpos
] )
ftp_put() 函數(shù)用來上傳由 local_file
參數(shù)指定的文件到 FTP 服務(wù)器,上傳后的位置由
remote_file
指定。傳輸模式參數(shù)
參數(shù)
ftp_stream
FTP 連接資源。
remote_file
遠(yuǎn)程文件路徑。
local_file
本地文件路徑。
mode
傳送模式,只能為 FTP_ASCII
(文本模式)或 FTP_BINARY
(二進(jìn)制模式)。
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
參數(shù)。
參見
ftp_pasv() - 返回當(dāng)前 FTP 被動模式是否打開 ftp_fput() - 上傳一個已經(jīng)打開的文件到 FTP 服務(wù)器 ftp_nb_fput() - 將文件存儲到 FTP 服務(wù)器 (非阻塞) ftp_nb_put() - 存儲一個文件至 FTP 服務(wù)器(non-blocking)