I searched the other threads, but it can´t get any solution. I try to upload a file with PHP an cURL to a remote server. With pure FTP it works fine:
$fp = fopen('testfile.jpg', 'r');
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,"ftp://server.com/testfile.jpg");
curl_setopt($curl, CURLOPT_USERPWD, "username:password");
curl_setopt($curl, CURLOPT_UPLOAD, 1);
curl_setopt($curl, CURLOPT_INFILE, $fp);
curl_exec ($curl);
curl_close ($curl);
But switching to SFTP or even SCP does not work. I tried SFTP by putting an s prior to the URL (sftp://server.com/testfile.jpg) and added the additional code line curl_setopt($curl, CURLPROTO_SFTP, 1);
No success. I get this error: Upload failed: Operation failed (4/-31)
What can I do? Any suggestions? Thank you