如何从网址PHP下载wav或mp3文件?身份验证后播放我的剪辑的 URL


How to download wav or mp3 file from url PHP? Url playing my clip after authentication

I used the following code to play my url and its working fine.
<video controls="" autoplay="" name="media"><source src="url.wav" type="audio/x-wav"></video>

并尝试了以下代码下载

header('Content-Type: audio/x-wav');
$file = "url.wav";
if( !file_exists($file) ) die("File not found");
header("Content-Disposition: attachment; filename=" . basename($file) . "");
header("Content-Length: " . filesize($file));
header('Content-Type: audio/x-wav, audio/wav');
readfile($file);

我正在使用 Yii 框架视图文件中的所有代码。

Yii 中,您可以在控制器中执行以下操作:

return Yii::app()->request->sendFile($file, @file_get_contents($file),'audio/x-wav');