FTP Class (myftp.php)

Source: Internet
Author: User
Tags ftp ftp connection connect
Class Myftp {

var $connector;
var $getback;

Function Connect ($ftp _server, $uname, $passwd) {
Baut Grundlegende FTP Connection auf
$this->connector = @ftp_connect ($ftp _server);
$this->login_result = @ftp_login ($this->connector, "$uname", "$passwd");
if (! $this->connector) | | (! $this->login_result))
{
echo "FTP Connection has failed! \ n ";
echo "Attempted to connect to $ftp _server for user $uname \ n";
Die
} else {
echo "Connected to $ftp _server, for user $uname \ n";
}
}

function Lastmodtime ($value) {
$getback = Ftp_mdtm ($this->connector, $value);
return $getback;
}

function Changedir ($targetdir) {
$getback = Ftp_chdir ($this->connector, $targetdir);
return $getback;
}
function Getdir () {
$getback = ftp_pwd ($this->connector);
return $getback;
}

function Get_file_list ($directory) {
$getback = Ftp_nlist ($this->connector, $directory);
return $getback;
}

function Get_file ($file _to_get, $mode, $mode 2) {
$realfile = basename ($file _to_get);
$filename = $realfile;

$checkdir = @ $this->changedir ($realfile);
if ($checkdir = = TRUE) {
Ftp_cdup ($this->connector);
echo "\n[dir] $realfile";
}else{
echo "..... ". $realfile. " \ n ";
$getback = Ftp_get ($this->connector, $filename, $realfile, $mode);
if ($mode 2) {
$delstatus = Ftp_delete ($this->connector, $file _to_get);
if ($delstatus = = TRUE) {
echo "File $realfile on $host deleted \ n";
}
}
}
return $getback;
}

function mode ($pasvmode) {
$result = FTP_PASV ($this->connector, $pasvmode);
}

function Ftp_bye () {
Ftp_quit ($this->connector);
return $getback;
}
}

?>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.