Created
October 24, 2018 20:13
-
-
Save mig1098/3fba46b07a1ecc5fc0e219f6ad02aa6d to your computer and use it in GitHub Desktop.
headers for download wav audio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ctype ='audio/x-wav'; | |
$filepath = '/var/www/html/audio.wav'; | |
$size = filesize($filepath); | |
$name = basename($filepath); | |
$fp=fopen($fichero, "rb"); | |
if ($size && $ctype && $fp) { | |
header("Pragma: public"); | |
header("Expires: 0"); | |
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); | |
header("Cache-Control: public"); | |
header("Content-Description: wav file"); | |
header("Content-Type: " . $ctype); | |
header("Content-Disposition: attachment; filename=" . $name); | |
header("Content-Transfer-Encoding: binary"); | |
header("Content-length: " . $size); | |
ob_clean(); | |
fpassthru($fp); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//another way | |
header('Content-Description: File Transfer'); | |
header('Content-Type: application/octet-stream'); | |
header('Content-Disposition: attachment; filename='.basename($destination_name_ulaw)); | |
header('Content-Transfer-Encoding: binary'); | |
header('Expires: 0'); | |
header('Cache-Control: must-revalidate'); | |
header('Pragma: public'); | |
header('Content-Length: ' . filesize($destination_name_ulaw)); | |
ob_clean(); | |
flush(); | |
readfile($destination_name_ulaw); | |
exit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment