Delphi6

BANNED | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Austral Вот тебе исходник дальше переделай, этот подточен чисто для моих целей, если что добавь доп. функции: Код: class ftpOp { var $connID; var $connected = false; var $errorMsg = array(); function addError($msg) { array_push($this->errorMsg, $msg); } function ftpOp($server, $user, $pass) { if ($this->connID = @ftp_connect($server)) { if (@ftp_login($this->connID, $user, $pass)) { if (@ftp_pasv($this->connID, true)) { $this->connected = true; return true; } else { $this->addError("Could not turn on passive mode"); return false; } } else { $this->addError("Could not login with follwoing username/password: $user/$pass"); return false; } } else { $this->addError("Could not connect to $server"); return false; } } function getFile($fileName) { if ($this->connected) { $tempFile = SERVER_PATH.TEMP_PATH."/ftp_temp_file"; if (@ftp_get($this->connID, $tempFile, $fileName, FTP_BINARY)) { return implode('', file($tempFile)); } else { $this->addError("Can not download $fileName file"); return false; } } else { $this->addError("There is not connection"); return false; } } function putFile($fileName, $buffer) { if ($this->connected) { $tempFile = SERVER_PATH.TEMP_PATH."/ftp_temp_file"; // try to delete file if exist @unlink($tempFile); // write buffer to temporary file $fp = fopen($tempFile, 'w'); fwrite($fp, $buffer); fclose($fp); // strat uploading if (ftp_put($this->connID, $fileName, $tempFile, FTP_BINARY)) { return true; } else { $this->addError("Can not upload $fileName file"); return false; } } else { $this->addError("There is not connection"); return false; } } function makeDir($dirName) { if ($this->connected) { if (@ftp_mkdir($this->connID, $dirName)) { return true; } else { $this->addError("Can not create $dirName directory"); return false; } } else { $this->addError("There is not connection"); return false; } } } |
|