Skip to content

Instantly share code, notes, and snippets.

@mig1098
Created October 24, 2018 20:13
Show Gist options
  • Save mig1098/3fba46b07a1ecc5fc0e219f6ad02aa6d to your computer and use it in GitHub Desktop.
Save mig1098/3fba46b07a1ecc5fc0e219f6ad02aa6d to your computer and use it in GitHub Desktop.
headers for download wav audio
$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);
}
//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