Mit PHP mp3-Download anbieten

Mit folgendem Code kann man mp3-Dateien zum Download anbieten ohne die Datei direkt zu verlinken:

<span style="color: #000000">
<span style="color: #0000bb">
&lt;?php
$mm_type</span><span style="color: #007700">=</span><span style="color: #dd0000">"application/octet-stream"</span><span style="color: #007700">;</span></span>

header(“Cache-Control: public, must-revalidate”);
header(“Pragma: hack”);
header(“Content-Type: ” . $mm_type);
header(“Content-Length: ” .(string)(filesize($path)) );
header(‘Content-Disposition: attachment; filename=”‘.$name.‘”‘);
header(“Content-Transfer-Encoding: binary\n”);

readfile($path);
?>

Habe es auf php.net gefunden und für meine Bedürfnisse umgeschrieben. :)

Comments are closed.