ftp_fput
(PHP 4, PHP 5, PHP 7)
ftp_fput - 从打开的文件上传到FTP服务器
描述
bool ftp_fput ( resource $ftp_stream , string $remote_file , resource $handle , int $mode [, int $startpos = 0 ] )
ftp_fput()将数据从文件指针上传到FTP服务器上的远程文件。
参数
ftp_stream
FTP连接的链接标识符。
remote_file
远程文件路径。
handle
本地文件上的打开文件指针。读取在文件结尾处停止。
mode
传输模式。必须是FTP_ASCII
或者FTP_BINARY
。
startpos
开始上传到远程文件的位置。
返回值
成功时返回TRUE
或失败时返回FALSE
。
例子
示例#1 ftp_fput()示例
<?php
//?open?some?file?for?reading
$file?=?'somefile.txt';
$fp?=?fopen($file,?'r');
//?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);
//?try?to?upload?$file
if?(ftp_fput($conn_id,?$file,?$fp,?FTP_ASCII))?{
????echo?"Successfully?uploaded?$file\n";
}?else?{
????echo?"There?was?a?problem?while?uploading?$file\n";
}
//?close?the?connection?and?the?file?handler
ftp_close($conn_id);
fclose($fp);
?>
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com