I'm having trouble using PHP to upload SFTP files to a remote server. When I use cURL, I get the error described here:
PHP SFTP - undefined constant CURLOPT_PROTOCOLS and CURLPROTO_SFTP?
I also tried phpseclib as suggested in:
SFTP from within PHP
But when I try to use phpseclib, I get the following errors:
Warning: require_once(Math/BigInteger.php) [function.require-once]: failed to open stream: No such file or directory in /home/john/public_html/test/Net/SSH2.php on line 53 Fatal error: require_once() [function.require]: Failed opening required 'Math/BigInteger.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/john/public_html/test/Net/SSH2.php on line 53
Then I tried using system commands in php, but nothing happened:
<?php echo system('sftp user@ftp.domain.com '); echo system('password'); echo system('put file.csv'); ?>
I also tried
<?php $connection = ssh2_connect('shell.example.com', 22); ssh2_auth_password($connection, 'username', 'password'); ssh2_scp_send($connection, '/local/filename', '/remote/filename', 0644); ?>
but my php server says ss2_connect is not defined.
I tried to do the following from the terminal
scp file.csv user@ftp.remote.com password
But the server does not allow the scp command. I do not have shell access to create ssh keys.
All I can do right now is sftp from the terminal and load manually. But I really want to automate this, so a PHP site can do it all.
There are not many manuals for downloading SFTP with PHP. Is it because it is bad? If so, what should I do? The server I want to load only allows sftp connections.