更改服务器后,readfile() 脚本不起作用


readfile() script not working after changing server

我有一个有效的代码,在这里:

if (isset($_GET['file']) && isset($_GET['name']))
{
$file = base64_decode($_REQUEST['file']);
$ch = curl_init($file);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
$data = curl_exec($ch);
curl_close($ch);
if (preg_match('/Content-Length: ('d+)/', $data, $matches)) 
{
    // Contains file size in bytes
    $contentLength = (int)$matches[1];
}
header("Content-type: application/x-file-to-save");
header("Content-Disposition: attachment; filename=".$_REQUEST['name']);
header('Content-Length: ' . $contentLength);
header('Content-Transfer-Encoding: binary');
@readfile($file);
}

然后我把我的服务器改成了不同的主机供应商,代码停止了工作。当我从chrome下载时,它只是不断加载和加载,但是当我从像 IDM 这样的下载管理器下载时,它会得到正确的名称和大小,但是当我按开始时,它会出现一个错误,说明不支持恢复或其他什么......

同样,当我使用不同的提供者时,代码有效。

可能是

在使用ob_clean(); flush();之前输出的错误readfile() readfile之前删除任何输出