/**
* @(#)dbutil.php
* PHP version 4.3.6
*
*
* Copyright 2008 SoftRoad. All Rights Reserved.
*
*====================================================================
* 変更履歴
*
* 新規作成 2008 年02月25日 蒋彪
*/
class FtpUtil{
/*FTPサバIP*/
var $ftp_server = "192.168.1.224";
/*FTPサパユーザー名*/
var $ftp_user = "mysearch";
/*FTPサパパースウード*/
var $ftp_pass = "mysearch";
/*源ファイル*/
var $source_file="../soft/11a1.jpg"; //源ファイル
/*目標ファイル*/
var $destination_file="/home/mysearch/11a1.jpg"; //目標ファイル
/*接続号*/
var $conn_id;
/**
*FTPサバIPを設定する。
*/
function setFtpServer($ftp_server){
$this->ftp_server=$ftp_server;
}
/**
*FTPサパユーザー名を設定する。
*/
function setFtpUser($ftp_user){
$this->ftp_user=$ftp_user;
}
/**
*FTPサバパースウードを設定する。
*/
function setFtpPass($ftp_pass){
$this->ftp_pass=$ftp_pass;
}
/**
*アップロードの源ファイルを設定する。
*/
function setSourceFile($source_file){
$this->source_file=$source_file;
}
/**
*アップロードの目標ファイルを設定する。
*/
function setDestFile($destination_file){
$this->destination_file=$destination_file;
}
/**
*FTPサバConnectionオブジェクトをゲットする。
*/
function connectFtpServer(){
// set up a connection or die
$conn_id = ftp_connect($this->ftp_server) or die("Couldn't connect to $ftp_server");
$login_result = ftp_login($conn_id, $this->ftp_user, $this->ftp_pass);
if ((!$conn_id) || (!$login_result)) { echo "FTP connection has failed!"; echo "Attempted to connect to $this->ftp_server for user $this->ftp_user_name"; exit; } else { echo "Connected to $this->ftp_server, for user $this->ftp_user_name"; } $this->conn_id=$conn_id; return $conn_id; } /** *FTPサバConnectionをクローズする。 */ function closeConnect(){ if($this->conn_id){ @ftp_close($this->conn_id); } } /** *ファイルをアップロード */ function upLoad(){ $upload = ftp_put($this->conn_id, $this->destination_file, $this->source_file, FTP_BINARY) or die("Couldn't connect to $this->ftp_server"); ftp_quit($this->conn_id); if (!$upload) { echo "FTP upload has failed!"; } else { echo "Uploaded $this->source_file to $this->ftp_server as $this->destination_file"; } }}?>