This code is really useful to download files (i.e. an mp3 file). It will tell the browser about the file type you’re about to download while also customizing the file name of it:
header('Content-type: audio/mpeg');
header('Content-Disposition: attachment; filename="'.$name.'.mp3"');
readfile($link);
Now we just need to provide the $name
and $link
variables for it to work.
This piece of code was borrowed from Michael Pardo. Thank you!
No comments yet