ssh2_scp_send keeps failing on SFTP

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Nov 16, 2017 11:45 am

Thu Nov 16, 2017 12:03 pm

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

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

Even i have read write permissions to that sftp folder

Code: Select all

$server = '';
$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);
return ":)";

Post Reply