Mit PHP mp3-Download anbieten
Monday, 17 December 2007
Mit folgendem Code kann man mp3-Dateien zum Download anbieten ohne die Datei direkt zu verlinken:
<span style="color: #000000">
<span style="color: #0000bb">
<?php
$mm_type</span><span style="color: #007700">=</span><span style="color: #dd0000">"application/octet-stream"</span><span style="color: #007700">;</span></span>
<span style="color: #0000bb">
<?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. :)