码迷,mamicode.com
首页 > Web开发 > 详细

php的ftp类

时间:2017-01-08 19:21:33      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:参考资料   path   guid   lib   amp   style   host   pat   nbsp   

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类

标签:参考资料   path   guid   lib   amp   style   host   pat   nbsp   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!