是否可以在
PHP中强制下载远程文件而不将其读入内存?我知道fpassthru(),readfile(),file_get_contents()都会在将文件输出到浏览器之前将文件读入内存.
这是我的代码:
if($url = getRemoteFileURL($file_id))
{
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="abc.zip"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Pragma: no-cache');
readfile($url); // is there a better function ?
}
我不想做标题(“位置:”),因为这会显示URL