当我打开此链接时
的download.php DIR =文件\特殊下载和安培;文件=女佣-与最亚麻色-hair.mp3
发生错误,如
警告:无法修改标头信息 - 已由(
)发送的标头这是我的PHP代码
$files = new filemanager;
$dir = $files->get_absolute_path($_GET['dir']);
$filemg=explode('.',$_GET['file']);
$dwfile=$files->seo_friendly_url($filemg[0]).'.'.$filemg[1];
if (isset($_GET['file']))
{
$file=$dir.DIRECTORY_SEPARATOR.$dwfile;
$files->downloadFile($file);
}
我使用这个类
function downloadFile($dwf) {
$file=str_replace('-',' ',$dwf);
$ar_ext = explode('.',$file);
$ext = strtolower(end($ar_ext));
$extensions = array(
'mp3' =>'audio/mp3'
);
$ctype = isset($extensions[$ext]) ? $extensions[$ext] : 'application/force-download';
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
readfile($file);
}