Ok vì vậy tôi có mã này sẽ cho phép người dùng tải về một bài hátDấu cách trong tên đang vi phạm bản tải xuống?
$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');
Vấn đề là nếu bài hát có một không gian trong nó như sinsita happy 1 SONIFI.mp3
người dùng sẽ chỉ tải về một tập tin văn bản có tên sinsita
.. ý tưởng Bất cứ làm thế nào để sửa chữa hành vi này
Xem http://stackoverflow.com/questions/93551/how-to-encode-the-filename-parameter-of-content-disposition-header-in- http –