-1

Im trying to upload an image to a sftp server with the following code:

//$this->sftp is a fully functioning ssh2_sftp variable
$remotefile = "filename.jpg";
$url = "ssh2.sftp://". intval($this->sftp)."/".$remoteFile;

The image gets uploaded but the server returns a 502 HTTP Error.

I tried without the slash $url = "ssh2.sftp://". intval($this->sftp)."/".$remoteFile; but I get the following error

Failed to open stream: operation failed

alex55132
  • 177
  • 1
  • 14
  • What is generating the error? I don't think you're getting an HTTP error from an SSH connection. – Alex Howansky Jan 30 '21 at 18:36
  • Well, that's the question. The connection is not SSH but SFTP, and I don't really understand why adding a backslash makes the server return a 502 :C @AlexHowansky – alex55132 Jan 30 '21 at 19:13

1 Answers1

-1

I found the issue, as this process is async I was closing the sftp connection before the process finished, triggering the 502 error.

alex55132
  • 177
  • 1
  • 14