Jump to content

ssh2_scp_send failing on SFTP


Geek4

Recommended Posts

Hi Fellows,

 

I am having trouble sending a file to SFTP and error coming in line 14 

 

Warning: ssh2_scp_send(): Failure creating remote file: (null) in path on line 14

 

fyi, i have read write permissions to that sftp folder 

 

<?php

 
$server = 'sftp.my.com';
$port = '22';
$username = 'myLogin';
$passwd = 'Pa$$w0rd';
$localFile = '000001.txt';
 
 
$connection = ssh2_connect($server, $port);
if (ssh2_auth_password($connection, $username, $passwd)) {
echo "Connection successful, uploading file now...</br>";
$sftp = ssh2_sftp($connection);
$sftp = ssh2_scp_send($connection, "000001.txt", "/upload/".$localFile, 0644);
if($sftp){
echo"<h1>Success</h1>";
return ":)";
}

upload.php

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.