Skip to content

Instantly share code, notes, and snippets.

@efiku
Created April 3, 2016 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save efiku/6acde9f5f50858e8fd7d10db0421c84d to your computer and use it in GitHub Desktop.
Save efiku/6acde9f5f50858e8fd7d10db0421c84d to your computer and use it in GitHub Desktop.
<?php
$file = "file.mp3";
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Expires: 0');
header('Content-Length: ' . filesize($file));
$fp = fopen($file, 'rb');
fpassthru($fp);
exit();
@efiku
Copy link
Author

efiku commented Apr 4, 2016

Testowane na dockerowym kontenerze nginx + php7, działa jak trzeba.
odradzam dodawanie $_GET jako nazwe pliku, bo.... ktoś Ci zassa cały serwis ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment