繁体   English   中英

我可以通过 php 将桌面文件上传到远程 SSH 服务器吗?

[英]Can I upload a desktop file to a remote SSH server via php?

首先,我对 php 很陌生,所以请耐心等待。 我想知道是否可以使用 php 将桌面上的文件上传到远程 SHH 服务器。 如果有帮助,我有 IP 地址、端口号、用户名和密码,但不知道如何解决这个问题。 我读到使用 html 帖子只允许您将文件上传到本地服务器,而不是远程服务器。 有任何想法吗?

phpseclib有一个基于类的接口,用于与 SFTP 交互。

例如:

require __DIR__ . '/vendor/autoload.php';

use phpseclib\Net\SFTP;

$sftp = new SFTP('www.domain.tld');
if (!$sftp->login('username', 'password')) {
    exit('Login Failed');
}

// puts a three-byte file named filename.remote on the SFTP server
$sftp->put('filename.remote', 'xxx');
// puts an x-byte file named filename.remote on the SFTP server,
// where x is the size of filename.local
$sftp->put('filename.remote', 'filename.local', SFTP::SOURCE_LOCAL_FILE);

SFTP 文档: http : //phpseclib.sourceforge.net/sftp/intro.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM