好吧,我有这个代码,允许用户下载一首歌
- $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的文本文件…任何想法如何解决这个问题