简介:
class ftp
{
public $off; // 返回操作状态(成功/失败)
public $conn_id; // FTP连接
function __construct($FTP_HOST,$FTP_PORT,$FTP_USER,$FTP_PASS)
{
$this->conn_id = @ftp_connect($FTP_HOST,$FTP_PORT) or die("FTP服务器连接失败");
@ftp_login($this->conn_id,$FTP_USER,$FTP_PASS) or die("FTP服务器登陆失败");
@ftp_pasv($this->conn_id,1); // 打开被动模拟
}
function up_file($path,$newpath,$type=true)
{
if($type) $this->dir_mkdirs($newpath);
$this->off = @ftp_put($this->conn_id,$newpath,$path,FTP_BINARY);
if(!$this->off) echo "文件上传失败,请检查权限及路径是否正确!";
}
方法:FTP连接
@FTP_HOST -- FTP主机
@FTP_PORT -- 端口
@FTP_USER -- 用户名
@FTP_PASS -- 密码