其实这个和循环遍历文件夹下的所有文件类似 但是一些函数不能在这里用 只能用ftp的函数
下面是代码
这个一个ftp类 里面已经封住好方法 大家调用就好
<?php
/**
* 仿写CodeIgniter的FTP类
* FTP基本操作:
* 1) 登陆; connect
* 2) 当前目录文件列表; filelist
* 3) 目录改变; chgdir
*
* @author quanshuidingdang
*/
class Ftp {
private $hostname = '';
private $username = '';
private $password = '';
private $port = 21;
private $passive = TRUE;
private $debug = TRUE;
private $conn_id = FALSE;
/**
* 构造函数
*
* @param array 配置数组 : $config = array('hostname'=>'','username'=>'','password'=>'','port'=>''...);
*/
public function __construct($config = array()) {
if(count($config) > 0) {
$this->_init($config);
}
}
/**
* FTP连接
*
* @access public
* @param array 配置数组
* @return boolean
*/
public function connect($config = array()) {
if(count($config) > 0) {
$this->_init($config);
}
if(FALSE === ($this->conn_id = @ftp_connect($this->hostname,$this->port))) {
if($this->debug === TRUE) {
$this->_error("ftp_unable_to_connect");