新建文件download.php,键入以下代码:
<?php
$fileName = $_GET['file'];
$file = 'music/' . $fileName;
if (!file_exists($file)) {
http_response_code(404);
die();
}
header("Cache-Control: private");
header("Content-type: audio/mpeg3");
header("Content-Transfer-Encoding: binary");
header("Content-Disposition: attachment; filename=".$fileName);
//So the browser can display the download progress
header("Content-Length: ".filesize($file));
readfile($file);
本文为“老吴笔记”的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。