Hello their i am getting error in this code with trellis server but it is working on other server perfectly
<?php
$localfile = 'test.txt';
$sftpServer = 'x';
$sftpUsername = 'x';
$sftpPassword = 'x';
$sftpPort = 22;
$sftpRemoteDir = '/';
$ch = curl_init('sftp://' . $sftpServer . ':' . $sftpPort . $sftpRemoteDir . '/' .
basename($localfile));
$fh = fopen($localfile, 'r');
if ($fh) {
curl_setopt($ch, CURLOPT_USERPWD, $sftpUsername . ':' . $sftpPassword);
curl_setopt($ch, CURLOPT_UPLOAD, true);
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_SFTP);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
// curl_setopt($ch, CURLOPT_FTP_SSL, FALSE);
curl_setopt($ch, CURLOPT_INFILE, $fh);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));
curl_setopt($ch, CURLOPT_VERBOSE, true);
$verbose = fopen('php://temp', 'w+');
curl_setopt($ch, CURLOPT_STDERR, $verbose);
$response = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
if ($response) {
echo "Success";
} else {
echo "Failure";
rewind($verbose);
$verboseLog = stream_get_contents($verbose);
echo "Verbose information:\n" . $verboseLog . "\n";
}
}
?>
The error i got in my trellis server
The error is: "resource(3) of type (stream) FailureVerbose information: * Trying ipaddredds:22... * TCP_NODELAY set * Connected to ftp.example.ch (ip addreass) port 22 (#0) * User: user* Failure establishing ssh session * Closing connection 0 "