Dear libssh2 group,
This is the 2nd time I'm posting this. The last attempt didn't get
through and isn't in the Archive.
Please, I need the simplest possible PHP coding example of using libssh
or libssh2 to upload a single file using the sftp protocol in the
following environment: Windows, PHP running via a local server URL in a
browser (for example, the URL might be "localhost/upload.php"). My
actual application is considerably more complex, but this simple example
is all I need to get started.
I have downloaded zip file php_ssh2-1.2-7.4-ts-vc15-x64, and it contains
php_ssh2.dll, which I assume goes into the PHP/ext directory/folder. I'm
not aware of any other installation required.
I've been trying to understand this library for several weeks
(part-time), including trying to read https://www.php.net/ssh2, and just
been frustrated. I'm a beginner when it comes to cryptography.
So I am looking for SIMPLE instructions and a single example of simple
PHP code to upload a file using sftp.
It should look something like the following working insecure example,
but include a local encrypted (preferred) or unencrypted private key
pathnanme. It may optionally include the certificate pathname, if that
is required. It should not prompt the user for any information, just
upload the file silently like the following working code does insecurely:
exit("Cannot connect to remote server (host)");
exit("Cannot login to remote server (host)");
exit("Cannot copy file '$file' to '$remoteDir$file' on remote server");
echo "...successfully done".<br>;
exit("*** Config file '$file' is missing from $pagesDir)";
} // GetConfigArr
Received on 2021-01-17