php sftp上传下载代码

代码语言:php

所属分类:上传

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<?php
class SFTPConnection
{
    private $connection;
    private $sftp;

    public function __construct($host, $port = 22) {
        $this->connection = @ssh2_connect($host, $port);
        if (! $this->connection)
            throw new Exception("Could not connect to$host on port $port.");
    }

    public function login($username, $password) {
        if (! @ssh2_auth_password($this->connection, $username, $password))
            throw new Exception("Could not authenticate with username$username " .
            "and password $password.");

        $this->sftp = @ssh2_sftp($this->connection);
        if (! $this->sftp)
            throw new Exception("Could not initialize SFTP subsystem.");
    }

    public function uploadFile($local_file, $remote_file) {
        $sftp = $this-.........完整代码请登录后点击上方下载按钮下载查看

网友评论0