0



I'm trying to download a file from 2 different folders in a SFTP. First file is in a directory with a " " in folder (ex. path/t o/file/a.pdf), second file is in a "normal" folder (ex. path2/to2/folder2/b.pdf).

If I try to download first file I have an error "unable to reach remote file", but with the second one I can download it correctly
This is what I'm doing

$connection = ssh2_connect(self::_URL_, self::_PORT_);
ssh2_auth_password($connection, self::_USER_, self::_PWD_);
$sftp = ssh2_sftp($connection);
    if (!$sftp) {
       //Error 
    } else {
        $folder = str_replace(" ","\ ",$folder);
        $stringa = 'ssh2.sftp://{$sftp}/path/{$folder}/pdf/'.$file;
        if (!$remote = @fopen($striga ,'r'))
        {
            throw new \Exception("Unable to open remote file: $file");
        }
    ...
    }

I've tried to use "pure" $folder and apply escapeshellarg, but nothing changes. What I have to apply to that folder?

Thanks

Andrea Mason
  • 239
  • 1
  • 2
  • 14

0 Answers0