1

How to avoid this error

Fatal error: Allowed memory size of 209715200 bytes exhausted

The files are very large (over 5gb)

$host = 'domain.com';
$pass = 'xxx';

$remote = "sftp://root:$pass@$host/var/www/test.txt";
$local = 'C:\wamp\www\test.txt';

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $remote);
curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_SFTP);
curl_setopt($curl, CURLOPT_USERPWD, "root:$pass");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
file_put_contents($local, curl_exec($curl));
curl_close($curl);
clarkk
  • 27,151
  • 72
  • 200
  • 340

1 Answers1

0

Have a look at the CURLOPT_FILE option. It will write the data directly to the given file.

isanae
  • 3,253
  • 1
  • 22
  • 47