2

I am trying to download a zip file from remote server to local in PHP using phpseclib, I have found a code that lets me upload but I couldn't find anything to download. Here is the code that I found on stackoverflow to upload :

 <?php

$cwd = getcwd();// . "/updater/";
set_include_path(get_include_path() . PATH_SEPARATOR . $cwd . '/phpseclib/');


require_once('Net/SSH2.php');
require_once('Net/SCP.php');


$ssh = new Net_SSH2('remote_ip');
if (!$ssh->login('remote user', 'remote_pwd'))
{
    throw new Exception("Failed to login");
}

$scp = new Net_SCP($ssh);
if (!$scp->put('remote_path',
   'local_path',
   NET_SCP_LOCAL_FILE))
{
    throw new Exception("Failed to send file");
}

?>

I also tried to switch between the remote_file and the local_file but that will not work.

Thanks in advance.

MuhammadNe
  • 674
  • 4
  • 11
  • 24

0 Answers0