Php 下载文件sftp,curl内存不足

Php 下载文件sftp,curl内存不足,php,curl,sftp,Php,Curl,Sftp,如何避免这个错误 Fatal error: Allowed memory size of 209715200 bytes exhausted 文件非常大(超过5gb) 看一看这张照片。它将数据直接写入给定的文件。请查看。它将数据直接写入给定的文件 $host = 'domain.com'; $pass = 'xxx'; $remote = "sftp://root:$pass@$host/var/www/test.txt"; $local = 'C:\wamp\www\test.txt';

如何避免这个错误

Fatal error: Allowed memory size of 209715200 bytes exhausted
文件非常大(超过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);