I’m using phpseclib – SFTP class and am trying to upload a file like so –
$sftp = new Net_SFTP('mydomain.com');
if (!$sftp->login('user', 'password')) {
exit('Login Failed');
}
$sftp->put('/some-dir/',$fileTempName);
The file however isn’t being uploaded inside some-dir but is uploaded one directory before (to the starting directory, lets say it’s root). This is driving me crazy, I think I’ve tried all combinations of some-dir/ or /some-dir or /some-dir/, but the file won’t upload there.
I don’t think your put is doing what you think it is doing. According to the docs, you need to do a
Net_SFTP::chdir('/some-dir/')to switch to the directory you want to send file to, thenput($remote_file, $data), whereremote_fileis the name of file, and$datais the actual file data.Example Code: