ftp_fput
(PHP 4, PHP 5)
ftp_fput — 上传一个已经打开的文件到 FTP 服务器
说明
bool ftp_fput ( resource $ftp_stream , string $remote_file , resource $handle , int $mode [, int $startpos ] )
ftp_fput() 函数用来上传一个在已经打开的文件中的数据到 FTP 服务器,参数 handle 为所打开文件的句柄。参数 remote_file 为上传到服务器上的文件名。传输模式参数 mode 只能为 (文本模式) FTP_ASCII 或 (二进制模式) FTP_BINARY 其中的一个。
Example #1 ftp_fput() example
<?php
// open some file for reading
$file = 'somefile.txt';
$fp = fopen($file, 'r');
// connect to the server
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// try to upload the file
if(ftp_fput($conn_id, $file, $fp, FTP_ASCII)) {
echo "Successfully uploaded $file ";
} else {
echo "There was a problem while uploading $file ";
}
// close the connection and the file handler
ftp_close($conn_id);
fclose($fp);
?>
Note:
参数 startpos 只适用于 4.3.0 以上版本。
成功时返回 TRUE, 或者在失败时返回 FALSE.
参见 ftp_put(),ftp_nb_fput() 和 ftp_nb_put()。
—-想了解更多的php相关异常处理怎么解决关注<计算机技术网(www.ctvol.com)!!>
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/phpttorial/84394.html