/**
* 功能:FTP操作類別( 拷貝、移動、刪除檔案/建立目錄 )
* 遠端上傳檔案
* 時間:2011216
* 作者:劉猛
*
*/
class class_ftp
{
public $off; // 返回作業狀態(成功/失敗)
*/
function __construct($FTP_HOST,$FTP_PORT,$FTP_USER,$FTP_PASS)
{
$4-1 月 {
@ftp_login ($this->conn_id,$FTP_USER,$FTP_PASS) or die("FTP伺服器登陸失敗");
@ftp_pasv($this->conn_id,1); // 開啟被動模擬 @ftp_pasv($this->conn_id,1); // 開啟被動模擬 @ftp_pasv($this->conn_id,1); // 開啟被動模擬#&*/
function up_file($path,$newpath,$type=false)
{
$thisds->off = @ftp_put($this ->conn_id,$newpath,$path,FTP_BINARY);
if(!$this->off) echo "檔案上傳失敗,請檢查權限及路徑是否正確!"; /
function move_file($path,$newpath,$type=true)
{
$this->conn_id, $path,$newpath);
);
if(!$this->off) echo "檔案移動失敗,請檢查權限及原路徑是否正確!";
} /p. $path,$newpath,$type=true)
{
$downpath = "c:/tmp.dat";
;// 下載
if(!$this->off) echo "檔案複製失敗,請檢查權限及原路徑是否正確! ";
$this->up_file($downpath,$newpath,$type);
}
$this->off = @ftp_delete( $this->conn_id,$path);
if(!$this->off) echo "檔案刪除失敗,請檢視權限及路徑是否正確! ";
}
/**
* 方法:FTP連線
* @FTP_HOST -- FTP主機
* @FTP_PORT --
*/
function dir_mkdirs($path)
{
$path_arr = explode('/',$path); // $path_div = count($path_arr ); // 取層數
foreach($path_arr as $val) // 建立目錄
{ ALSE)
{
$tmp = @ftp_mkdir ($this->conn_id,$val);
if($tmp == FALSE)
echo "目錄建立失敗,請檢查權限及路徑是否正確!";
@ftp_chdir($this ->conn_id,$val);
}
}
{
@ftp_cdup($this->conn_id);
}
}
/**
* 方法:關閉FTP連線
*/
function close()
{
}
?>
//使用方法
$ftp = new class_ftp( '172.15.0.46',21,'zengzhi','aipu2010');
$ftp->up_file($_FILES['Game_src']['tmp_name'],'/G/'.$_FILES['Game_src)' ['name']);
$ftp->close();
$src_img='http://172.15.0.46/G/'.$_FILES['Game_src']['name'];