(实用篇)PHP ftp上传文件操作类
<?php /** * 作用:FTP操作类( 拷贝、移动、删除文件/创建目录 ) */ class class_ftp { public $off; // 返回操作状态(成功/失败) public $conn_id; // FTP连接 const FTP_HOST='*.*.*.*'; const FTP_PORT='21'; const FTP_USER='*******'; const FTP_PASS='*******'; /** * 方法:FTP连接 * @FTP_HOST -- FTP主机 * @FTP_PORT -- 端口 * @FTP_USER -- 用户名 * @FTP_PASS -- 密码 */ function __construct() { $this->conn_id = @ftp_connect(self::FTP_HOST,self::FTP_PORT) or die("FTP服务器连接失败"); @ftp_login($this->conn_id,self::FTP_USER,self::FTP_PASS) or die("FTP服务器登陆失败"); @ftp_pasv($this->conn_id,1); // 打开被动模拟 } /** * 方法:上传文件 * @path -- 本地路径 * @newpath -- 上传路径 * @type --