There is a file I want to read from another server via SFTP and .pem key.
I made connection to server and it was successful now when reading the file from server using this line
// Connect to SFTP
$sftp = new SFTP($host, $port);
if (!$sftp->login($username, $key)) {
exit('Login Failed');
}
// Read a remote file
$remoteFile = '/path/to/file.log';
$content = $sftp->get($remoteFile);
I am getting below error.
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 98566176 bytes) in /var/www/Utility/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php on line 2461
I tried the following code
$stream = $sftp->getStream('largefile.dat');
if ($stream) {
while (!feof($stream)) {
$chunk = fread($stream, 8192);
// Process $chunk
}
fclose($stream);
}
But it gives the error
Undefined method ‘getStream’.intelephense(P1013)
I tried checking everything php phpseclib installation is proper.