简体   繁体   English

如何通过PHP连接到SFTP服务器

[英]How to connect to sftp server via php

I am using PHP , I want to connect to remote server in SFTP, but the website said: Fatal error: Call to undefined function ssh2_connect() in D:\\xampp\\htdocs\\dive\\database.php on line 9 我正在使用PHP,我想连接到SFTP中的远程服务器,但是网站说: 致命错误:在第9行的D:\\ xampp \\ htdocs \\ dive \\ database.php中调用未定义的函数ssh2_connect()

Can you tell me in detail how to do this? 您能详细告诉我该怎么做吗? I tired 我累了

<?php
$connection = ssh2_connect('ftp.server.com', 22); 
if (ssh2_auth_password($connection, 'username', 'password')) 
    echo "Authentication success";
else 
    echo "Authentication failure";
?>

But it doesn't work. 但这是行不通的。

After I connect to the server, is there a difference if I want to insert some data to the table in it? 连接到服务器后,是否要向其中的表中插入一些数据,会有区别吗? Which function should I use? 我应该使用哪个功能?

Have you installed / verified via phpinfo() that ssh2 is installed? 您是否已通过phpinfo()安装/验证是否已安装ssh2? Quick Google search seems to indicate it is not by default PHP Install SSH2 on Windows machine 快速Google搜索似乎表明默认情况下它不是PHP PHP在Windows计算机上安装SSH2

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

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