getting error with curl and trellis php wordpress

孤街醉人 提交于 2020-12-23 13:45:24

问题


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 "

来源:https://stackoverflow.com/questions/65359210/getting-error-with-curl-and-trellis-php-wordpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!