Answer the question
In order to leave comments, you need to log in
How to download mp3 using php?
I'm making a music player for a website.
There is a music archive, the user needs to give music through a php file.
Php loader looks like this:
$file = $_GET['music'];
$mp3 = file_get_contents($_SERVER['DOCUMENT_ROOT']."/".$file);
$file_size= filesize($_SERVER['DOCUMENT_ROOT']."/".$file);
header("Content-Type: audio/mpeg");
header("Accept-Ranges: bytes");
header("Content-Length: " . $file_size);
echo $mp3;
<audio src="download.php?music=test.mp3" controls type="audio/mp3" ></audio>
Answer the question
In order to leave comments, you need to log in
in Dolphin and Chrome the script works. By the way, what is the name parameter for?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question