问题
I could not copy the file with spaces in file name using ssh2_scp_recv() function.This is the filename testfile-03_23_15 11 02 AM.csv which actually stored in server.
my code is here
if ($file == "testfile-03_23_15 11 02 AM.csv"){
if(!ssh2_scp_recv($connection,$remoteDir .$file, $localDir . $file)){
echo "Could not download: ", $remoteDir, $file, "\n";
}
}
Please help me if you know. Thanks.
回答1:
With phpseclib:
<?php
include 'phpseclib/Net/SSH2.php';
include 'phpseclib/Net/SCP.php';
$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
exit('bad login');
}
$scp = new Net_SCP($ssh);
$scp->get('file name with spaces');
回答2:
Try this one:
ssh2_scp_recv($connection,"\"".$remote_file_name."\"",$local_path."/".$remote_file_name);
Source: php.net
It says: Trying to get a remote file with spaces in its name? Never forget to use quotes in the remote filename, but never in the local one.
来源:https://stackoverflow.com/questions/30194011/could-not-copy-file-name-with-space-in-scp-ssh