我开发了一个从服务器下载 MP3 文件的代码。该代码适用于旧服务器,但不适用于新服务器。当我尝试下载罚款时它显示0字节
我通过 HTTP Post 方法发送下载链接
www.example.com/download.php?dlink=http://www.example.com/music/sample.mp3
这是我使用的代码
ob_start();
if(isset($_REQUEST['dlink']))
{
$file = $_REQUEST['dlink'];
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
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: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
ob_flush();
提前致谢