【发布时间】:2015-10-15 10:50:53
【问题描述】:
我试图在用户访问此站点时强制浏览器下载 mp3。我遇到的问题是,如果我设置 Content-Length 标头,页面会引发 502 Bad Gateway 错误,如果我不这样做,它会尝试下载文件,但文件大小为 0 字节。该网站恰好在运行 wordpress。任何方向将不胜感激。我不熟悉wordpress。
$file = '../uploads/2015/01/Thunder.mp3';
header('Content-type: application/mp3');
header("Content-Disposition: attachment; filename=\"$file\"");
header('Content-Length: '.filesize($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
【问题讨论】:
标签: php wordpress download http-headers