首页 > Web开发 > 详细

php的ftp类

时间:2017-01-08 19:18:36      阅读:197      评论:0      收藏:0      [点我收藏+]

1.需求

了解php的ftp使用

2.例子

使用CI封装好的ftp类库

上传
$this->load->library(‘ftp‘);

$config[‘hostname‘] = ‘ftp.example.com‘;
$config[‘username‘] = ‘your-username‘;
$config[‘password‘] = ‘your-password‘;
$config[‘debug‘]    = TRUE;

$this->ftp->connect($config);
//路径要绝对路径
$this->ftp->upload(‘/local/path/to/myfile.html‘, ‘/public_html/myfile.html‘, ‘ascii‘, 0775);

$this->ftp->close();
下载文件列表
$this->load->library(‘ftp‘);

$config[‘hostname‘] = ‘ftp.example.com‘;
$config[‘username‘] = ‘your-username‘;
$config[‘password‘] = ‘your-password‘;
$config[‘debug‘]    = TRUE;

$this->ftp->connect($config);

$list = $this->ftp->list_files(‘/public_html/‘);

print_r($list);

$this->ftp->close();

 

参考资料:

http://codeigniter.org.cn/user_guide/libraries/ftp.html

http://php.net/manual/zh/book.ftp.php

 

php的ftp类

原文:http://www.cnblogs.com/norm/p/6262473.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!