php的ftp类

时间:2017-01-08 19:18:36   收藏:0   阅读:199

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

 

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!