Home > php教程 > php手册 > body text

php ftp函数文件上传

WBOY
Release: 2016-06-13 11:17:22
Original
1081 people have browsed it

其它很多时间我们不会用于php ftp函数文件上传哦,但有在使用比较高级的WEB应用时就会用到关于ftp功能,如我现在要把上传的图片传B服务器,数据保存到A服务器,普通的php文件上传实例不了,但用ftp功能就可以方便的实例了。  

其它很多时间我们不会用于php教程 ftp函数文件上传哦,但有在使用比较高级的WEB应用时就会用到关于ftp功能,如我现在要把上传的图片传B服务器,数据保存到A服务器,普通的php文件上传实例不了,但用ftp功能就可以方便的实例了。

// 定义变量
$local_file = 'local.zip';
$server_file = 'server.zip';
// 连接FTP服务器
$conn_id = ftp_connect($ftp_server);
//验证登录服务器
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// 下载文件
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
    echo "下载 $local_file 文件成功 n";
} else {
    echo "下载失败n";
}
// 关闭ftp连接
ftp_close($conn_id);
?> 


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!