简体   繁体   中英

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

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? Quick Google search seems to indicate it is not by default PHP Install SSH2 on Windows machine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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