我开发一个代码从服务器下载MP3文件。该代码在旧服务器中工作,但不适用于新服务器。它显示了0字节,当我尝试下载一个精细在php下载文件不起作用
我发送通过HTTP POST methos下载链接
www.example.com/download.php?dlink=http://www.example.com/音乐/ 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();
感谢代码
什么是$文件这里读取文件($文件)? – Venu
$ file = $ _REQUEST ['dlink']; 我错过了这一行,现在我添加了..请看看这个问题.... –
你想输出文件,这是要获取另一台服务器?或者是位于该服务器中的文件? – Venu