【发布时间】:2011-06-29 02:57:59
【问题描述】:
好的,我有这个代码可以让用户下载歌曲
$file = DIR_DOWNLOAD . $download_info->row['filename'];
$mask = basename($download_info->row['mask']);
$mime = 'application/octet-stream';
$encoding = 'binary';
if (!headers_sent()) {
if (file_exists($file)) {
header('Pragma: public');
header('Expires: 0');
header('Content-Description: File Transfer');
header('Content-Type: ' . $mime);
header('Content-Transfer-Encoding: ' . $encoding);
header('Content-Disposition: attachment; filename=' . ($mask ? $mask : basename($file)));
header('Content-Length: ' . filesize($file));
$file = readfile($file, 'rb');
问题在于,如果歌曲中包含 sinsita happy 1 SONIFI.mp3 之类的空格,则用户只会下载名为 sinsita 的文本文件...任何想法如何解决此问题
【问题讨论】:
标签: php file header download pragma