Php 卷曲度+;通过浏览器下载文件

Php 卷曲度+;通过浏览器下载文件,php,curl,download,save,Php,Curl,Download,Save,当我使用cURL下载一些文件时,cURL会将文件打印到浏览器中。但我想打开“保存到”浏览器下载窗口。我该怎么做 $c = curl_init(); curl_setopt($c, CURLOPT_URL, $url); curl_setopt($c, CURLOPT_POSTFIELDS, "file_name=test.rar"); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_FOLLOWLOCA

当我使用cURL下载一些文件时,cURL会将文件打印到浏览器中。但我想打开“保存到”浏览器下载窗口。我该怎么做

$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_POSTFIELDS, "file_name=test.rar");
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
curl_exec($c);
curl_close($c);

我得到内存泄漏致命错误:允许的内存大小为67108864字节depustduse
ini_set('memory_limit','128M')ini_set('memory_limit','128M');
$content = curl_exec($c);
curl_close($c);

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=your_file.txt');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . strlen($content));
ob_clean();
flush();
echo $content;
flush();